Skip to content

Commit

Permalink
playlist_index respects playlist_items (closes #10591)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesmana committed Sep 11, 2016
1 parent be45730 commit 7bbb700
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions youtube_dl/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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]

Expand All @@ -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']),
Expand Down

0 comments on commit 7bbb700

Please sign in to comment.