pull/12023/head
7x11x13 7 months ago
parent a6068e695c
commit 200d27682d

@ -720,7 +720,7 @@ class TestYoutubeDL(unittest.TestCase):
ydl._num_downloads = 1
self.assertEqual(ydl.validate_outtmpl(tmpl), None)
out = ydl.evaluate_outtmpl_for_filename(tmpl, info or self.outtmpl_info)
out = ydl.evaluate_outtmpl(tmpl, info or self.outtmpl_info, trim_filename=True)
fname = ydl.prepare_filename(info or self.outtmpl_info)
if not isinstance(expected, (list, tuple)):

@ -1425,12 +1425,11 @@ class YoutubeDL:
return EXTERNAL_FORMAT_RE.sub(create_key, outtmpl), TMPL_DICT
def evaluate_outtmpl(self, outtmpl, info_dict, *args, **kwargs):
def evaluate_outtmpl(self, outtmpl, info_dict, *args, trim_filename=False, **kwargs):
outtmpl, info_dict = self.prepare_outtmpl(outtmpl, info_dict, *args, **kwargs)
return self.escape_outtmpl(outtmpl) % info_dict
if not trim_filename:
return self.escape_outtmpl(outtmpl) % info_dict
def evaluate_outtmpl_for_filename(self, outtmpl, info_dict, *args, **kwargs):
outtmpl, info_dict = self.prepare_outtmpl(outtmpl, info_dict, *args, **kwargs)
ext_suffix = '.%(ext\x00s)s' # not sure why this has null char
suffix = ''
if outtmpl.endswith(ext_suffix):
@ -1491,7 +1490,7 @@ class YoutubeDL:
outtmpl = self.params['outtmpl'].get(tmpl_type or 'default', self.params['outtmpl']['default'])
try:
outtmpl = self._outtmpl_expandpath(outtmpl)
filename = self.evaluate_outtmpl_for_filename(outtmpl, info_dict, True)
filename = self.evaluate_outtmpl(outtmpl, info_dict, True, trim_filename=True)
if not filename:
return None

Loading…
Cancel
Save