From b8344046138083152d9b0d9a5cc8a11e28faf621 Mon Sep 17 00:00:00 2001 From: dirkf Date: Thu, 27 Jan 2022 02:29:33 +0000 Subject: [PATCH] Fix/improve InAdvancePagedList, from yt-dlp d37707bda466282b66ce381cbfd734f899f9e06e --- youtube_dl/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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):