fix: Make sure that Jellyfin playlists are sorted and paginated (#1847)
authorJc2k <john.carr@unrouted.co.uk>
Thu, 9 Jan 2025 16:44:31 +0000 (16:44 +0000)
committerGitHub <noreply@github.com>
Thu, 9 Jan 2025 16:44:31 +0000 (17:44 +0100)
fix: Make sure that Jellyfin playlists are sorted correctly and track fetching is paginated

music_assistant/providers/jellyfin/__init__.py
music_assistant/providers/jellyfin/manifest.json
requirements_all.txt

index 7c79b1e4ba4c8b890fa3f68316066860d424f64f..3390ee336268144613ff732b985ce6ac06ebcdea 100644 (file)
@@ -410,23 +410,21 @@ class JellyfinProvider(MusicProvider):
     async def get_playlist_tracks(self, prov_playlist_id: str, page: int = 0) -> list[Track]:
         """Get playlist tracks."""
         result: list[Track] = []
-        if page > 0:
-            # paging not supported, we always return the whole list at once
-            return []
-        # TODO: Does Jellyfin support paging here?
         playlist_items = (
-            await self._client.tracks.parent(prov_playlist_id)
+            await self._client.tracks.in_playlist(prov_playlist_id)
             .enable_userdata()
             .fields(*TRACK_FIELDS)
+            .limit(100)
+            .start_index(page * 100)
             .request()
         )
         for index, jellyfin_track in enumerate(playlist_items["Items"], 1):
+            pos = (page * 100) + index
             try:
                 if track := parse_track(
                     self.logger, self.instance_id, self._client, jellyfin_track
                 ):
-                    if not track.position:
-                        track.position = index
+                    track.position = pos
                     result.append(track)
             except (KeyError, ValueError) as err:
                 self.logger.error(
index cf9cca560a8115e2e41bb96b0a916d5ee420b0c3..af85a57b7e6904d374821938550778ff46a40830 100644 (file)
@@ -4,7 +4,7 @@
   "name": "Jellyfin Media Server Library",
   "description": "Support for the Jellyfin streaming provider in Music Assistant.",
   "codeowners": ["@lokiberra", "@Jc2k"],
-  "requirements": ["aiojellyfin==0.10.1"],
+  "requirements": ["aiojellyfin==0.11.2"],
   "documentation": "https://music-assistant.io/music-providers/jellyfin/",
   "multi_instance": true
 }
index c2cde8b66b496a6243eb80a960ba251b5d0db0c4..1455e75e3f7fecbefd047a56990e998c55fd1131 100644 (file)
@@ -4,7 +4,7 @@ Brotli>=1.0.9
 aiodns>=3.0.0
 aiofiles==24.1.0
 aiohttp==3.11.6
-aiojellyfin==0.10.1
+aiojellyfin==0.11.2
 aiorun==2024.8.1
 aioslimproto==3.1.0
 aiosonos==0.1.7