mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
Fix bug in 07a1250e0e
This commit is contained in:
parent
7657ec7ed6
commit
48c8424bd9
|
@ -2813,13 +2813,16 @@ def _forceprint(self, key, info_dict):
|
||||||
info_copy['automatic_captions_table'] = self.render_subtitles_table(info_dict.get('id'), info_dict.get('automatic_captions'))
|
info_copy['automatic_captions_table'] = self.render_subtitles_table(info_dict.get('id'), info_dict.get('automatic_captions'))
|
||||||
|
|
||||||
def format_tmpl(tmpl):
|
def format_tmpl(tmpl):
|
||||||
mobj = re.fullmatch(r'([\w.:,-]|(?P<dict>{[\w.:,-]+}))+=', tmpl)
|
mobj = re.fullmatch(r'([\w.:,]|-\d|(?P<dict>{([\w.:,]|-\d)+}))+=?', tmpl)
|
||||||
if not mobj:
|
if not mobj:
|
||||||
return tmpl
|
return tmpl
|
||||||
elif not mobj.group('dict'):
|
|
||||||
return '\n'.join(f'{f} = %({f})r' for f in tmpl[:-1].split(','))
|
fmt = '%({})s'
|
||||||
tmpl = f'.{tmpl[:-1]}' if tmpl.startswith('{') else tmpl[:-1]
|
if tmpl.startswith('{'):
|
||||||
return f'{tmpl} = %({tmpl})#j'
|
tmpl = f'.{tmpl}'
|
||||||
|
if tmpl.endswith('='):
|
||||||
|
tmpl, fmt = tmpl[:-1], '{0} = %({0})#j'
|
||||||
|
return '\n'.join(map(fmt.format, [tmpl] if mobj.group('dict') else tmpl.split(',')))
|
||||||
|
|
||||||
for tmpl in self.params['forceprint'].get(key, []):
|
for tmpl in self.params['forceprint'].get(key, []):
|
||||||
self.to_stdout(self.evaluate_outtmpl(format_tmpl(tmpl), info_copy))
|
self.to_stdout(self.evaluate_outtmpl(format_tmpl(tmpl), info_copy))
|
||||||
|
|
Loading…
Reference in a new issue