From 7bbb700c7119a274b982cb250741b62d152705f9 Mon Sep 17 00:00:00 2001 From: Lesmana Zimmer Date: Sun, 11 Sep 2016 23:31:07 +0200 Subject: [PATCH] playlist_index respects playlist_items (closes #10591) --- youtube_dl/YoutubeDL.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 805733fb7a57..881879dbbfd3 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -795,7 +795,7 @@ def iter_playlistitems(format): yield int(item) else: yield int(string_segment) - playlistitems = iter_playlistitems(playlistitems_str) + playlistitems = list(iter_playlistitems(playlistitems_str)) ie_entries = ie_result['entries'] if isinstance(ie_entries, list): @@ -836,6 +836,14 @@ def iter_playlistitems(format): '[%s] playlist %s: Downloading %d videos' % (ie_result['extractor'], playlist, n_entries)) + if playlistitems: + playlistindexes = playlistitems + else: + playlistindexes = range(playliststart + 1, playlistend + 1) + + for entry, index in zip(entries, playlistindexes): + entry['index'] = index + if self.params.get('playlistreverse', False): entries = entries[::-1] @@ -846,7 +854,7 @@ def iter_playlistitems(format): 'playlist': playlist, 'playlist_id': ie_result.get('id'), 'playlist_title': ie_result.get('title'), - 'playlist_index': i + playliststart, + 'playlist_index': entry['index'], 'extractor': ie_result['extractor'], 'webpage_url': ie_result['webpage_url'], 'webpage_url_basename': url_basename(ie_result['webpage_url']),