aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2021-05-03 20:41:33 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2021-05-03 22:49:05 +0530
commitf59ae58163ae801e06f77618b3a87514852b5f7f (patch)
tree16c5c351541f91bea55ae7a84c1633950f043583
parent0d1bb027aab2aa96be12caac8ed9bcd5e0d3a2f5 (diff)
downloadhypervideo-pre-f59ae58163ae801e06f77618b3a87514852b5f7f.tar.lz
hypervideo-pre-f59ae58163ae801e06f77618b3a87514852b5f7f.tar.xz
hypervideo-pre-f59ae58163ae801e06f77618b3a87514852b5f7f.zip
Fix number of digits in `%(playlist_index)s`
When used with `--playlist-(items|start|end)`, the number of digits should depend on the last index in the playlist, not number of items
-rw-r--r--yt_dlp/YoutubeDL.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py
index 98f320b2e..0791cfd9c 100644
--- a/yt_dlp/YoutubeDL.py
+++ b/yt_dlp/YoutubeDL.py
@@ -827,7 +827,7 @@ class YoutubeDL(object):
# For fields playlist_index and autonumber convert all occurrences
# of %(field)s to %(field)0Nd for backward compatibility
field_size_compat_map = {
- 'playlist_index': len(str(template_dict.get('n_entries', na))),
+ 'playlist_index': len(str(template_dict.get('_last_playlist_index') or '')),
'autonumber': autonumber_size,
}
FIELD_SIZE_COMPAT_RE = r'(?<!%)%\((?P<field>autonumber|playlist_index)\)s'
@@ -1348,6 +1348,7 @@ class YoutubeDL(object):
entry['__x_forwarded_for_ip'] = x_forwarded_for
extra = {
'n_entries': n_entries,
+ '_last_playlist_index': max(playlistitems) if playlistitems else (playlistend or n_entries),
'playlist': playlist,
'playlist_id': ie_result.get('id'),
'playlist_title': ie_result.get('title'),