Fix/improve `InAdvancePagedList`

This commit is contained in:
pukkandan 2022-01-23 23:25:17 +05:30
parent f40ee5e9a0
commit d37707bda4
No known key found for this signature in database
GPG Key ID: 0F00D95A001F4698
2 changed files with 5 additions and 2 deletions

View File

@ -72,6 +72,7 @@ from .utils import (
GeoRestrictedError,
get_domain,
HEADRequest,
InAdvancePagedList,
int_or_none,
iri_to_uri,
ISO3166Utils,
@ -1662,6 +1663,9 @@ class YoutubeDL(object):
msg = 'Downloading %d videos'
if not isinstance(ie_entries, (PagedList, LazyList)):
ie_entries = LazyList(ie_entries)
elif isinstance(ie_entries, InAdvancePagedList):
if ie_entries._pagesize == 1:
playlist_count = ie_entries._pagecount
def get_entry(i):
return YoutubeDL.__handle_extraction_exceptions(

View File

@ -2845,8 +2845,7 @@ class InAdvancePagedList(PagedList):
def _getslice(self, start, end):
start_page = start // self._pagesize
end_page = (
self._pagecount if end is None else (end // self._pagesize + 1))
end_page = self._pagecount if end is None else min(self._pagecount, end // self._pagesize + 1)
skip_elems = start - start_page * self._pagesize
only_more = None if end is None else end - start
for pagenum in range(start_page, end_page):