diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-07-22 07:52:55 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2023-07-22 08:57:43 +0530 |
commit | a264433c9fba147ecae2420091614186cfeeb895 (patch) | |
tree | 2a03d3e994bfc8801f990aed8dc5f63c237ec0d0 | |
parent | 9f66247289b9f8ecf931833b3f5f127274dd2161 (diff) | |
download | hypervideo-pre-a264433c9fba147ecae2420091614186cfeeb895.tar.lz hypervideo-pre-a264433c9fba147ecae2420091614186cfeeb895.tar.xz hypervideo-pre-a264433c9fba147ecae2420091614186cfeeb895.zip |
[outtmpl] Fix replacement for `playlist_index`
-rw-r--r-- | test/test_YoutubeDL.py | 1 | ||||
-rw-r--r-- | yt_dlp/YoutubeDL.py | 8 |
2 files changed, 5 insertions, 4 deletions
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index b4f770ca5..c54c3ea5c 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -687,6 +687,7 @@ class TestYoutubeDL(unittest.TestCase): test('%(duration_string)s', ('27:46:40', '27-46-40')) test('%(resolution)s', '1080p') test('%(playlist_index|)s', '001') + test('%(playlist_index&{}!)s', '001!') test('%(playlist_autonumber)s', '02') test('%(autonumber)s', '00001') test('%(autonumber+2)03d', '005', autonumber_start=3) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 324f9e99c..dae29d9f9 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -1300,16 +1300,16 @@ class YoutubeDL: else: break - fmt = outer_mobj.group('format') - if fmt == 's' and value is not None and last_field in field_size_compat_map.keys(): - fmt = f'0{field_size_compat_map[last_field]:d}d' - if None not in (value, replacement): try: value = replacement_formatter.format(replacement, value) except ValueError: value, default = None, na + fmt = outer_mobj.group('format') + if fmt == 's' and last_field in field_size_compat_map.keys() and isinstance(value, int): + fmt = f'0{field_size_compat_map[last_field]:d}d' + flags = outer_mobj.group('conversion') or '' str_fmt = f'{fmt[:-1]}s' if value is None: |