diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-09-06 19:56:56 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-09-06 19:57:29 +0530 |
commit | 48c8424bd9e03fdfd5c4c4495de233e896eb1f16 (patch) | |
tree | 47a8beb7ab1f43741ded79a6cafeb049123aafb5 | |
parent | 7657ec7ed6318dd66dd72cc100ba7bc5b911366e (diff) | |
download | hypervideo-pre-48c8424bd9e03fdfd5c4c4495de233e896eb1f16.tar.lz hypervideo-pre-48c8424bd9e03fdfd5c4c4495de233e896eb1f16.tar.xz hypervideo-pre-48c8424bd9e03fdfd5c4c4495de233e896eb1f16.zip |
Fix bug in 07a1250e0e90515ff8142161536f9dafa6eaba1b
-rw-r--r-- | yt_dlp/YoutubeDL.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 58c5c4750..99db8be92 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -2813,13 +2813,16 @@ class YoutubeDL: info_copy['automatic_captions_table'] = self.render_subtitles_table(info_dict.get('id'), info_dict.get('automatic_captions')) 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: return tmpl - elif not mobj.group('dict'): - return '\n'.join(f'{f} = %({f})r' for f in tmpl[:-1].split(',')) - tmpl = f'.{tmpl[:-1]}' if tmpl.startswith('{') else tmpl[:-1] - return f'{tmpl} = %({tmpl})#j' + + fmt = '%({})s' + if tmpl.startswith('{'): + 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, []): self.to_stdout(self.evaluate_outtmpl(format_tmpl(tmpl), info_copy)) |