From 23de6822ae4f2c8ebee89aa0a165a8195aff66dd Mon Sep 17 00:00:00 2001 From: MoojMidge <56883549+MoojMidge@users.noreply.github.com> Date: Sat, 16 Dec 2023 07:00:44 +1100 Subject: [PATCH] Fix initial discard of subsequent pages of playlistitems --- .../youtube/helper/resource_manager.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/resources/lib/youtube_plugin/youtube/helper/resource_manager.py b/resources/lib/youtube_plugin/youtube/helper/resource_manager.py index 8e29b9ece..37e2429d4 100644 --- a/resources/lib/youtube_plugin/youtube/helper/resource_manager.py +++ b/resources/lib/youtube_plugin/youtube/helper/resource_manager.py @@ -86,7 +86,7 @@ def get_channels(self, ids): # Re-sort result to match order of requested IDs # Will only work in Python v3.7+ - if list(result) != ids: + if list(result) != ids[:len(result)]: result = { id: result[id] for id in ids @@ -149,7 +149,7 @@ def get_playlists(self, ids): # Re-sort result to match order of requested IDs # Will only work in Python v3.7+ - if list(result) != ids: + if list(result) != ids[:len(result)]: result = { id: result[id] for id in ids @@ -193,13 +193,20 @@ def get_playlist_items(self, ids=None, batch_id=None): .format(ids=list(result))) new_data = {} + insert_point = 0 for playlist_id, page_token in to_update: + new_batch_ids = [] + batch_id = (playlist_id, page_token) + insert_point = batch_ids.index(batch_id, insert_point) while 1: batch_id = (playlist_id, page_token) + new_batch_ids.append(batch_id) batch = self._client.get_playlist_items(*batch_id) new_data[batch_id] = batch page_token = batch.get('nextPageToken') if fetch_next else None if page_token is None: + batch_ids[insert_point:insert_point] = new_batch_ids + insert_point += len(new_batch_ids) break if new_data: @@ -213,7 +220,7 @@ def get_playlist_items(self, ids=None, batch_id=None): # Re-sort result to match order of requested IDs # Will only work in Python v3.7+ - if list(result) != batch_ids: + if list(result) != batch_ids[:len(result)]: result = { id: result[id] for id in batch_ids @@ -274,7 +281,7 @@ def get_videos(self, ids, live_details=False, suppress_errors=False): # Re-sort result to match order of requested IDs # Will only work in Python v3.7+ - if list(result) != ids: + if list(result) != ids[:len(result)]: result = { id: result[id] for id in ids