mirror of https://github.com/yt-dlp/yt-dlp.git
[outtmpl] Fix replacement for `playlist_index`
This commit is contained in:
parent
9f66247289
commit
a264433c9f
|
@ -687,6 +687,7 @@ class TestYoutubeDL(unittest.TestCase):
|
||||||
test('%(duration_string)s', ('27:46:40', '27-46-40'))
|
test('%(duration_string)s', ('27:46:40', '27-46-40'))
|
||||||
test('%(resolution)s', '1080p')
|
test('%(resolution)s', '1080p')
|
||||||
test('%(playlist_index|)s', '001')
|
test('%(playlist_index|)s', '001')
|
||||||
|
test('%(playlist_index&{}!)s', '001!')
|
||||||
test('%(playlist_autonumber)s', '02')
|
test('%(playlist_autonumber)s', '02')
|
||||||
test('%(autonumber)s', '00001')
|
test('%(autonumber)s', '00001')
|
||||||
test('%(autonumber+2)03d', '005', autonumber_start=3)
|
test('%(autonumber+2)03d', '005', autonumber_start=3)
|
||||||
|
|
|
@ -1300,16 +1300,16 @@ class YoutubeDL:
|
||||||
else:
|
else:
|
||||||
break
|
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):
|
if None not in (value, replacement):
|
||||||
try:
|
try:
|
||||||
value = replacement_formatter.format(replacement, value)
|
value = replacement_formatter.format(replacement, value)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
value, default = None, na
|
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 ''
|
flags = outer_mobj.group('conversion') or ''
|
||||||
str_fmt = f'{fmt[:-1]}s'
|
str_fmt = f'{fmt[:-1]}s'
|
||||||
if value is None:
|
if value is None:
|
||||||
|
|
Loading…
Reference in New Issue