aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-06-18 08:25:57 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-06-18 08:36:39 +0530
commitbf1824b391e2f18b7e927f54340c0aabfa9399cd (patch)
tree3729a7b8b92bb0ab49805c07692d239f1e227bf9
parenta70635b8a1bcf42bf587fe3cd7503f1d092009ce (diff)
downloadhypervideo-pre-bf1824b391e2f18b7e927f54340c0aabfa9399cd.tar.lz
hypervideo-pre-bf1824b391e2f18b7e927f54340c0aabfa9399cd.tar.xz
hypervideo-pre-bf1824b391e2f18b7e927f54340c0aabfa9399cd.zip
[cleanup] Deprecate `YoutubeDL.parse_outtmpl`
-rw-r--r--yt_dlp/YoutubeDL.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index fb3f9337f..f38697365 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -669,7 +669,7 @@ class YoutubeDL:
'Set the LC_ALL environment variable to fix this.')
self.params['restrictfilenames'] = True
- self.outtmpl_dict = self.parse_outtmpl()
+ self._parse_outtmpl()
# Creating format selector here allows us to catch syntax errors before the extraction
self.format_selector = (
@@ -996,21 +996,19 @@ class YoutubeDL:
self.report_warning(msg)
def parse_outtmpl(self):
- outtmpl_dict = self.params.get('outtmpl', {})
- if not isinstance(outtmpl_dict, dict):
- outtmpl_dict = {'default': outtmpl_dict}
- # Remove spaces in the default template
- if self.params.get('restrictfilenames'):
+ self.deprecation_warning('"YoutubeDL.parse_outtmpl" is deprecated and may be removed in a future version')
+ self._parse_outtmpl()
+ return self.params['outtmpl']
+
+ def _parse_outtmpl(self):
+ sanitize = lambda x: x
+ if self.params.get('restrictfilenames'): # Remove spaces in the default template
sanitize = lambda x: x.replace(' - ', ' ').replace(' ', '-')
- else:
- sanitize = lambda x: x
- outtmpl_dict.update({
- k: sanitize(v) for k, v in DEFAULT_OUTTMPL.items()
- if outtmpl_dict.get(k) is None})
- for _, val in outtmpl_dict.items():
- if isinstance(val, bytes):
- self.report_warning('Parameter outtmpl is bytes, but should be a unicode string')
- return outtmpl_dict
+
+ outtmpl = self.params.setdefault('outtmpl', {})
+ if not isinstance(outtmpl, dict):
+ self.params['outtmpl'] = outtmpl = {'default': outtmpl}
+ outtmpl.update({k: sanitize(v) for k, v in DEFAULT_OUTTMPL.items() if outtmpl.get(k) is None})
def get_output_path(self, dir_type='', filename=None):
paths = self.params.get('paths', {})
@@ -1248,7 +1246,7 @@ class YoutubeDL:
def _prepare_filename(self, info_dict, *, outtmpl=None, tmpl_type=None):
assert None in (outtmpl, tmpl_type), 'outtmpl and tmpl_type are mutually exclusive'
if outtmpl is None:
- outtmpl = self.outtmpl_dict.get(tmpl_type or 'default', self.outtmpl_dict['default'])
+ outtmpl = self.params['outtmpl'].get(tmpl_type or 'default', self.params['outtmpl']['default'])
try:
outtmpl = self._outtmpl_expandpath(outtmpl)
filename = self.evaluate_outtmpl(outtmpl, info_dict, True)
@@ -1878,7 +1876,7 @@ class YoutubeDL:
and (
not can_merge()
or info_dict.get('is_live') and not self.params.get('live_from_start')
- or self.outtmpl_dict['default'] == '-'))
+ or self.params['outtmpl']['default'] == '-'))
compat = (
prefer_best
or self.params.get('allow_multiple_audio_streams', False)
@@ -3224,7 +3222,7 @@ class YoutubeDL:
def download(self, url_list):
"""Download a given list of URLs."""
url_list = variadic(url_list) # Passing a single URL is a common mistake
- outtmpl = self.outtmpl_dict['default']
+ outtmpl = self.params['outtmpl']['default']
if (len(url_list) > 1
and outtmpl != '-'
and '%' not in outtmpl