Fix bugs in PlaylistEntries
This commit is contained in:
parent
d965856235
commit
bc5c2f8a2c
2 changed files with 9 additions and 6 deletions
|
@ -1816,7 +1816,7 @@ class YoutubeDL:
|
||||||
elif self.params.get('playlistrandom'):
|
elif self.params.get('playlistrandom'):
|
||||||
random.shuffle(entries)
|
random.shuffle(entries)
|
||||||
|
|
||||||
self.to_screen(f'[{ie_result["extractor"]}] Playlist {title}: Downloading {n_entries} videos'
|
self.to_screen(f'[{ie_result["extractor"]}] Playlist {title}: Downloading {n_entries} items'
|
||||||
f'{format_field(ie_result, "playlist_count", " of %s")}')
|
f'{format_field(ie_result, "playlist_count", " of %s")}')
|
||||||
|
|
||||||
keep_resolved_entries = self.params.get('extract_flat') != 'discard'
|
keep_resolved_entries = self.params.get('extract_flat') != 'discard'
|
||||||
|
@ -1849,7 +1849,7 @@ class YoutubeDL:
|
||||||
resolved_entries[i] = (playlist_index, NO_DEFAULT)
|
resolved_entries[i] = (playlist_index, NO_DEFAULT)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.to_screen('[download] Downloading video %s of %s' % (
|
self.to_screen('[download] Downloading item %s of %s' % (
|
||||||
self._format_screen(i + 1, self.Styles.ID), self._format_screen(n_entries, self.Styles.EMPHASIS)))
|
self._format_screen(i + 1, self.Styles.ID), self._format_screen(n_entries, self.Styles.EMPHASIS)))
|
||||||
|
|
||||||
extra.update({
|
extra.update({
|
||||||
|
@ -1867,8 +1867,11 @@ class YoutubeDL:
|
||||||
resolved_entries[i] = (playlist_index, entry_result)
|
resolved_entries[i] = (playlist_index, entry_result)
|
||||||
|
|
||||||
# Update with processed data
|
# Update with processed data
|
||||||
ie_result['requested_entries'] = [i for i, e in resolved_entries if e is not NO_DEFAULT]
|
|
||||||
ie_result['entries'] = [e for _, e in resolved_entries if e is not NO_DEFAULT]
|
ie_result['entries'] = [e for _, e in resolved_entries if e is not NO_DEFAULT]
|
||||||
|
ie_result['requested_entries'] = [i for i, e in resolved_entries if e is not NO_DEFAULT]
|
||||||
|
if ie_result['requested_entries'] == try_call(lambda: list(range(1, ie_result['playlist_count'] + 1))):
|
||||||
|
# Do not set for full playlist
|
||||||
|
ie_result.pop('requested_entries')
|
||||||
|
|
||||||
# Write the updated info to json
|
# Write the updated info to json
|
||||||
if _infojson_written is True and self._write_info_json(
|
if _infojson_written is True and self._write_info_json(
|
||||||
|
|
|
@ -2950,10 +2950,10 @@ class PlaylistEntries:
|
||||||
self.is_exhausted = True
|
self.is_exhausted = True
|
||||||
|
|
||||||
requested_entries = info_dict.get('requested_entries')
|
requested_entries = info_dict.get('requested_entries')
|
||||||
self.is_incomplete = bool(requested_entries)
|
self.is_incomplete = requested_entries is not None
|
||||||
if self.is_incomplete:
|
if self.is_incomplete:
|
||||||
assert self.is_exhausted
|
assert self.is_exhausted
|
||||||
self._entries = [self.MissingEntry] * max(requested_entries)
|
self._entries = [self.MissingEntry] * max(requested_entries or [0])
|
||||||
for i, entry in zip(requested_entries, entries):
|
for i, entry in zip(requested_entries, entries):
|
||||||
self._entries[i - 1] = entry
|
self._entries[i - 1] = entry
|
||||||
elif isinstance(entries, (list, PagedList, LazyList)):
|
elif isinstance(entries, (list, PagedList, LazyList)):
|
||||||
|
@ -3022,7 +3022,7 @@ class PlaylistEntries:
|
||||||
if not self.is_incomplete:
|
if not self.is_incomplete:
|
||||||
raise self.IndexError()
|
raise self.IndexError()
|
||||||
if entry is self.MissingEntry:
|
if entry is self.MissingEntry:
|
||||||
raise EntryNotInPlaylist(f'Entry {i} cannot be found')
|
raise EntryNotInPlaylist(f'Entry {i + 1} cannot be found')
|
||||||
return entry
|
return entry
|
||||||
else:
|
else:
|
||||||
def get_entry(i):
|
def get_entry(i):
|
||||||
|
|
Loading…
Reference in a new issue