diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index ba85a90af24..a85a70b86db 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -3931,7 +3931,8 @@ def getslice(self, start=0, end=None): res = [] start_page = start // self._pagesize end_page = ( - self._pagecount if end is None else (end // self._pagesize + 1)) + 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):