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

Playlists not syncing correctly from Jellyfin #3278

Open
1 task done
tanc opened this issue Dec 7, 2024 · 11 comments
Open
1 task done

Playlists not syncing correctly from Jellyfin #3278

tanc opened this issue Dec 7, 2024 · 11 comments
Assignees
Labels
bug Something isn't working Fix to be Confirmed

Comments

@tanc
Copy link

tanc commented Dec 7, 2024

What version of Music Assistant has the issue?

2.4.0b7

What version of the Home Assistant Integration have you got installed?

2024.12.1

Have you tried everything in the Troubleshooting FAQ and reviewed the Open and Closed Issues and Discussions to resolve this yourself?

  • Yes

The problem

When syncing a Jellyfin music provider with playlists, those playlists don't proper sync.

How to reproduce

Set up Music Assistant with a Jellyfin server music provider. Test that albums are syncing and can be played to confirm there is no issue with communication.

  1. Create a playlist in Jellyfin 10.10.3 with some tracks
  2. Go to Music Assistant and sync the Jellyfin music provider
  3. Go to the Playlists tab of Music Assistant and note that the playlist appears but:
  4. With a title "Playlist" and no tracks
  5. Not at all
  6. With the correct title but no tracks

Music Providers

Jellyfin

Player Providers

Web UI

Full log output

music-assistant.log

Additional information

In the logs I can see Sync task for Jellyfin Media Server Library completed with errors

What version of Home Assistant Core are your running

2024.12.1

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Linux

@tanc tanc added the triage label Dec 7, 2024
@OzGav
Copy link
Contributor

OzGav commented Dec 7, 2024

As requested in the issue template paste the full log

@tanc
Copy link
Author

tanc commented Dec 7, 2024

Is that not the full log? When I'm back at my machine I'll hunt to see if there is a fuller log

@OzGav
Copy link
Contributor

OzGav commented Dec 7, 2024

Sorry somehow I didn't see it at first glance. If you can fix that Sonos player problem which is spamming your log then that will make it easier to read. Once that is fixed then turn on debug logging for the Jellyfin provider, restart MA and then once the log says the sync for Jellyfin is complete then post the log again.

@tanc
Copy link
Author

tanc commented Dec 7, 2024

No problem. I've disabled the sonos integration and then enabled debug log level for the Jellyfin provider. I then did another sync and this is the log, starting from the point of enabling the debug log level:
music-assistant (1).log

@Jc2k
Copy link

Jc2k commented Dec 7, 2024

Can you turn on debug logging for "music controller" as well and try again.

If there's an exception while syncing it's logged under the music controller, not the provider.

@tanc
Copy link
Author

tanc commented Dec 8, 2024

With music controller debug logging turned on the updated log looks like this (truncated):
music-assistant (2).log

The exception(s):

Traceback (most recent call last):
  File "/app/venv/lib/python3.12/site-packages/aiojellyfin/session.py", line 69, in get_json
    resp = await self._session.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/aiohttp/client.py", line 827, in _request
    resp.raise_for_status()
  File "/app/venv/lib/python3.12/site-packages/aiohttp/client_reqrep.py", line 1150, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url='https://media.jampony.net/Users/5006413a420043e592f4b6dfb5e5e687/Items/9926862deffa9358d3bf529c82b37481?Fields=Path,Genres,SortName,Studios,Writer,Taglines,LocalTrailerCount,OfficialRating,CumulativeRunTimeTicks,ItemCounts,Metascore,AirTime,DateCreated,People,Overview,CriticRating,CriticRatingSummary,Etag,ShortOverview,ProductionLocations,Tags,ProviderIds,ParentId,RemoteTrailers,SpecialEpisodeNumbers,MediaSources,VoteCount,RecursiveItemCount,PrimaryImageAspectRatio'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/app/venv/lib/python3.12/site-packages/music_assistant/controllers/music.py", line 870, in run_sync
    async for _ in self.playlists.tracks(playlist.item_id, playlist.provider):
  File "/app/venv/lib/python3.12/site-packages/music_assistant/controllers/media/playlists.py", line 66, in tracks
    tracks = await self._get_provider_playlist_tracks(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/music_assistant/controllers/media/playlists.py", line 364, in _get_provider_playlist_tracks
    items = await provider.get_playlist_tracks(item_id, page=page)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/music_assistant/providers/jellyfin/__init__.py", line 398, in get_playlist_tracks
    jellyfin_playlist = await self._client.get_playlist(prov_playlist_id)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/venv/lib/python3.12/site-packages/aiojellyfin/__init__.py", line 129, in get_playlist
    await self._session.get_json(
  File "/app/venv/lib/python3.12/site-packages/aiojellyfin/session.py", line 82, in get_json
    raise NotFound("Resource not found")
aiojellyfin.session.NotFound: Resource not found

Could this be a playlist referring to a track item that doesn't exist that then causes a 404 error?

@OzGav
Copy link
Contributor

OzGav commented Dec 15, 2024

@Jc2k any thoughts?

@Jc2k
Copy link

Jc2k commented Jan 8, 2025

  • Playlist called "Playlist" - I've had a quick look and I can't see how that is us. We just pass the name straight from Jellyfin to the DB layer. The only thing I can think of is if the name was blank and somewhere we set the default to "Playlist". But I don't see any defaults like that in the code.
  • Playlists missing entirely - sync is aborting on first error, so some playlists are never attempted. So kind of expected.
  • Playlists empty - this is caused by the 404 error. The error is that the playlist itself is missing from Jellyfin, not the tracks. All I can think is MA is trying to access a Jellyfin playlist that it somehow knows about but really doesn't exist any more or that there is some permission thing (different user account and its a private playlist?). Can't see how we could make a playlist that didn't exist in Jellyfin at some point.

In music-assistant/server#1843 I was able to get rid of the API call that was failing. I suspect the playlist will still be empty, but the sync may otherwise finish without errors. Let's see what it does when the change is merged.

Other than that, if you can recreate the issue in a fresh MA with only Jellyfin, and the 404 is on first sync, then I might be able to write some python scripts to dump the raw output of the API calls the sync makes to get a better idea of whats happening. That will require using some python packaging tool like uv probably and setting up some rudimentary dev env, so not for everyone.

@Jc2k
Copy link

Jc2k commented Jan 9, 2025

music-assistant/server#1847 may also help. Rather than rely on a parent-child relationship existing between the playlist and its tracks, it uses an explicit playlist endpoint to fetch the playlist tracks. This was done to fix sorting, but its possible this playlist specific endpoint is accounting for some difference in our databases (its the endpoint that the jellyfin web interface uses, so if that works then MA should work).

@Jc2k
Copy link

Jc2k commented Jan 10, 2025

Both changes are in the latest beta (2.4.0b12) if you are able to test that.

@OzGav OzGav added bug Something isn't working Fix to be Confirmed and removed triage labels Jan 10, 2025
@OzGav
Copy link
Contributor

OzGav commented Jan 12, 2025

@tanc we will close this soon assuming fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fix to be Confirmed
Projects
None yet
Development

No branches or pull requests

3 participants