From 5bb36412bedae0eb711ecbbf1fd995223b4342e3 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Mon, 13 Apr 2026 15:17:52 -0700 Subject: [PATCH] Fix Jellyfin playlist track fetch truncating at default API limit get_playlist_tracks() had no Limit or StartIndex params, so Jellyfin defaulted to ~100 items per response. This caused the Server Playlists comparison to show most tracks as missing even though they were present. Now paginates in batches of 1000 until a partial batch signals the last page. --- core/jellyfin_client.py | 47 +++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/core/jellyfin_client.py b/core/jellyfin_client.py index da32a6c0..dac2212a 100644 --- a/core/jellyfin_client.py +++ b/core/jellyfin_client.py @@ -1470,28 +1470,39 @@ class JellyfinClient: """Get all tracks from a specific playlist""" if not self.ensure_connection(): return [] - + try: - params = { - 'ParentId': playlist_id, - 'IncludeItemTypes': 'Audio', - 'Recursive': True, - 'Fields': 'AlbumId,ArtistItems,Path,MediaSources', - 'SortBy': 'SortName', - 'SortOrder': 'Ascending' - } - - response = self._make_request(f'/Users/{self.user_id}/Items', params) - if not response: - return [] - tracks = [] - for item in response.get('Items', []): - tracks.append(JellyfinTrack(item, self)) - + start_index = 0 + limit = 1000 + + while True: + params = { + 'ParentId': playlist_id, + 'IncludeItemTypes': 'Audio', + 'Recursive': True, + 'Fields': 'AlbumId,ArtistItems,Path,MediaSources', + 'SortBy': 'SortName', + 'SortOrder': 'Ascending', + 'StartIndex': start_index, + 'Limit': limit, + } + + response = self._make_request(f'/Users/{self.user_id}/Items', params) + if not response: + break + + batch = response.get('Items', []) + for item in batch: + tracks.append(JellyfinTrack(item, self)) + + if len(batch) < limit: + break # Last page + start_index += limit + logger.debug(f"Retrieved {len(tracks)} tracks from playlist {playlist_id}") return tracks - + except Exception as e: logger.error(f"Error getting tracks for playlist {playlist_id}: {e}") return []