Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make sure that Jellyfin playlists are sorted and paginated #1847

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions music_assistant/providers/jellyfin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,23 +409,21 @@ async def get_playlist(self, prov_playlist_id: str) -> Playlist:
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(
Expand Down
2 changes: 1 addition & 1 deletion music_assistant/providers/jellyfin/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading