music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.32k stars 48 forks source link

Jellyfin integration is not receiving any tracks from the Jellyfin server #2135

Closed TastaturCrasher closed 2 months ago

TastaturCrasher commented 5 months ago

What version of Music Assistant has the issue?

2.0.0b137

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

2024.3.6

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

The problem

The Jellyfin integration fails to load any tracks or albums from my Jellyfin instance. The only things that are received by jellyfin are playlists (only the name of playlist and cover picture of the playlist) But the playlist in MA is completely empty, no songs are shown and there is an infinite loading bar displayed. If I search for tracks from my Jellyfin server, no results are displayed

My Jellyfin instance is running just fine and is able to provide the mentioned missing data in other 3rd party applications. The Jellyfin server is reachable and pingable from my HA instance.

To resolve this problem, I did try the following:

How to reproduce

Adding Jellyfin Media Server Library as a provider and fill in all appropriate login data (server IP, username, password)

Music Providers

Not working:

Working fine and without any issues:

Player Providers

-

Full log output

log.txt

Additional information

No response

What version of Home Assistant Core are your running

2024.4.3

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Alternative

OzGav commented 5 months ago

@TastaturCrasher are you the same as Swifty7640 on Discord?

TastaturCrasher commented 5 months ago

@OzGav No, sorry 😅

OzGav commented 5 months ago

@lokiberra second report

marcelveldt commented 4 months ago

Please test with b140 - I spotted some quick fixes base don the log reports, not sure if they actually work as I only have a very limited jellyfin test server installed.

TastaturCrasher commented 4 months ago

Tested with b141 and 2024.4.0 Nothing changed as far as I can tell.

I also did all the things again mentioned in my original post.

Log file attached. log2.txt

lokiberra commented 4 months ago

@marcelveldt I tested your fix with a playlist track that I removed the 'Album' metadata (aka ITEM_KEY_ALBUM). It proceeded to add the track to the playlist without error. I will do a update to also handle if ITEM_KEY_ALBUM is missing, but the parent ID is not (ITEM_KEY_PARENT_ID). This should also be able to find the album of the track.

OzGav commented 4 months ago

@TastaturCrasher Can you please check with b147 and advise of any improvements or change in behaviour

TastaturCrasher commented 4 months ago

Tested with b147. Currently I have two playlists created in Jellyfin. Only one of them now has the tracks showing up in Music Assistant. But the tracks can not be played and the cover images are missing. (see screenshot below) image

The other playlist comes with an error message 'Album Artist' and no tracks loaded. No albums or tracks are showing up in the respective Music Assistant menus. Log File Attached. log3.txt

OzGav commented 4 months ago

@lokiberra some more info

lokiberra commented 4 months ago

@TastaturCrasher Do you have no metadata for these tracks in Jellyfin? They should all have Artist tags if they have been correctly scraped and matched using Jellyfin. Otherwise Music Assistant will have to initially flag it as Various Artists.

TastaturCrasher commented 4 months ago

I just checked it and all the tracks do have an artist listed in their metadata. Not every artist may be set correctly as all tracks are converted YouTube videos and the metadata was set automatically, but I assume this shouldn't be a problem.

I loaded new tracks into Jellyfin yesterday, created a new playlist and reloaded everything from the Jellyfin provider in the Music Assistant settings (Synchronize now and Reload). Now all playlists show up correctly and all tracks are also loaded and can be played. In the playlists themselfes no cover images of the songs are showing up but in some areas they do. See the below screenshots.

Still all tracks are only accessible inside the playlists and don't show up in any other menu like artists, albuns or tracks. This is now on version 2.1.0b0 by the way.

image image 330846760-e04d2e81-1eb7-4c88-abd7-ecf9225550cc

beankylla commented 3 months ago

fun fact: with latest beta the scan of music takes 22h to complete and i only have ~1'000 songs in there (vs 1924 album found, so quite the gap)

florian-asche commented 3 months ago

fun fact: with latest beta the scan of music takes 22h to complete and i only have ~1'000 songs in there (vs 1924 album found, so quite the gap)

Hi, can you give me some hint, how did you configure your jellyfin instance? Mine is not loading any music info. Jellyfin 10.9.2 music assistant server 2.1.0b0, just updating to 2.1.0b1

I have an admin user just for musicassistant in jellyfin, pointed to jellyfin with port in the music-assistant configuration.

Why is it not working :/

OzGav commented 3 months ago

@lokiberra

lokiberra commented 3 months ago

@florian-asche @beankylla Could you provide logs to assess? The previous logs in this issue indicated and issue with metadata keys missing (ex. Artist) when MA was trying to parse a track. Logs would be helpful to see if it is the same issues or if there is another issue I can recreate to debug.

I have connect successfully with a 10.9.2 Jellyfin instance and had albums/artist/tracks/artist/playlists added. The user shouldn't matter as long as they have access to a 'Music' type of library. If your libraries are set up as another type they will be ignored. Has Jellyfin matched all your albums and added metadata using Musicbrainz or TheAudioDB? Do you files have correct tags and folder structures for Jellyfin to use when matching albums? Have you tried using the Home Assistant Jellyfin integration? Does it find all your albums and tracks? It also uses the Python API so it should be similar in functionality.

beankylla commented 3 months ago

Jellyfin 10.9.2 Musicassistant 2.1.0b1

I think i am "in line" with the comments here, i only have 2 errors in my logs: 1) the https one (other ticket open) 2) the missing artists one.

That said i don't think i'm missing the artist on all of the missing songs that I have. Is it possible that there is something leaving no trace in the logs?

All of my music is perfectly sorted (artists/albums)

Jellyfin : 1,974 albums Musicassistant : 1,924 albums

Jellyfin: Some playlists (one created in jellyfin, other are m3u files) Musicassistant: 0 playlists (only the random / favorite playlists)

Jellyfin: 37,571 songs Musicassistant: 1,054 songs (this number seems low vs the number of songs I see how is the number of songs counted?)

have not tried the jellyfin integration in HA will do so now and revert back

edit: the jellyfin integration in HA shows me no music at all just an error message XD. It connects properly and shows that Jellyfin is online but i cannot see any music inside HA.

2024-05-24 17:19:24.568 WARNING (MainThread) [music_assistant.providers.jellyfin] Skipping sync of item jellyfin://album/c0a6b8ae5051e0f9d9bfe2b74f68e21b - error details: Album is missing artist(s) 2024-05-24 17:19:24.592 WARNING (MainThread) [py.warnings] /usr/local/lib/python3.12/site-packages/urllib3/connectionpool.py:1103: InsecureRequestWarning: Unverified HTTPS request is being made to host 'my.media.server.URL'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings warnings.warn(

OzGav commented 3 months ago

I would assume if missing Artist is being reported then there is a tagging problem at the file level or a metadata problem at the Jellyfin level. Would you consider bypassing Jellyfin and just sharing the files with MA directly?

TastaturCrasher commented 3 months ago

I added some tracks via the local file system provider - no issues whatsoever. Tracks show up in the tracks, the artist, and the album section. Also showing all the metadata in MA including the cover image.

JhonnyMnemonic320 commented 3 months ago

MusicAssistant Version: 2.0.4 (installed using docker) Jellyfin Version: 10.9.2 (tested also with 10.8.3)

I'am using MusicAssistant with a specific non-Admin user for Jellyfin. The Jellyfin user wasn't able to stream any songs from MusicAssistant until I enabled "consent media download" for the user in the jellyfin server.

It seems like MusicAssistant is accessing the media provided by Jellyfin not as the other players (like Finamp, Gelli or Symfonium) so the user must have "media download" enabled.

I also found that a consequence of the way MusicAssistant consumes Jellyfin media is that jellyfin's scrobbler plug-ins (like last.fm or listenbrainz) don't report any song to the respective service.

OzGav commented 3 months ago

@TastaturCrasher does the post above help you?

TastaturCrasher commented 3 months ago

Nope, I use Jellyfin with an admin account and this option was already enabled all the time.

florian-asche commented 3 months ago

MusicAssistant Version: 2.0.4 (installed using docker) Jellyfin Version: 10.9.2 (tested also with 10.8.3)

I'am using MusicAssistant with a specific non-Admin user for Jellyfin. The Jellyfin user wasn't able to stream any songs from MusicAssistant until I enabled "consent media download" for the user in the jellyfin server.

It seems like MusicAssistant is accessing the media provided by Jellyfin not as the other players (like Finamp, Gelli or Symfonium) so the user must have "media download" enabled.

I also found that a consequence of the way MusicAssistant consumes Jellyfin media is that jellyfin's scrobbler plug-ins (like last.fm or listenbrainz) don't report any song to the respective service.

how do you run your music-assistant? with docker-compose or homeassistant addon?

beankylla commented 3 months ago

I would assume if missing Artist is being reported then there is a tagging problem at the file level or a metadata problem at the Jellyfin level. Would you consider bypassing Jellyfin and just sharing the files with MA directly?

hmmm i think if there is a solid jellyfin integration i would prefer that over sharing the files directly. It is the way i consume media so i hope in the future there will be sync in favorite songs etc,

Otherwise it's like maintaining 2 different databases ^^

Jc2k commented 3 months ago

Can anyone having problems try the latest beta? Obviously it's a beta, might eat your kitten, etc. Maybe try a second instance.

https://github.com/music-assistant/server/releases/tag/2.1.0b7

Quite a few changes have landed, and it fixed at least one case of "nothing synced" so far.

5000 tracks, 400 albums, sync in about 1 minute here when MA has an SSD and 10 minutes on 10 year old spinning rust (that's initial sync, updates are a minute).

florian-asche commented 2 months ago

I am not sure, but since the update of Jellyfin and MusicAssistant Beta it is working now ;) Jellyfin: 10.9.6 MusicAssistant-Server: 2.1.0b7

beankylla commented 2 months ago

hmm not sure for who it works or how it should work but it does not work for me. i have v2.1.0b8 and when i click sync jellyfin provider it does not add the remaining songs. For those with whom it worked how did you get it to work?

Best,

Jc2k commented 2 months ago

Can you start a new issue as it's likely a different issue.

Let me know if you see a message like "sync completed but with errors" in your logs. If you do, make sure you have debug logs turned on for the music controller and try to sync again. It should include the error if you do that correctly.

florian-asche commented 2 months ago

hmm not sure for who it works or how it should work but it does not work for me. i have v2.1.0b8 and when i click sync jellyfin provider it does not add the remaining songs. For those with whom it worked how did you get it to work?

Best,

Yeah its best to make seperated issues. I have an idea. Ive seen a setting, for how often it should sync with jellyfin, and my default was every 5min. If your sync takes longer, not sure, how it will handle that. Maybe it stops and restart again.

I synced 500+ Albums without issue. But it took a very long time. I am currently thinking about just buying a spotify account since all my songs i play often are there.

Jc2k commented 2 months ago

Yeah it's best to make seperated issues. I have an idea. Ive seen a setting, for how often it should sync with jellyfin, and my default was every 5min. If your sync takes longer, not sure, how it will handle that. Maybe it stops and restart again.

There is a lock to stop concurrent syncs. It doesn't cancel the active sync.

I synced 500+ Albums without issue. But it took a very long time. I am currently thinking about just buying a spotify account since all my songs i play often are there.

How slow? How many albums? How many artists and tracks? How fast was the 2nd sync?

I can pull 400 albums in a minute over a vpn if the MA db is on SSD (a 7 year old one at that). Even though my jellyfin instance is on spinning rust. It's much slower if the MA db is on a slow disk. Maybe 15-20 minutes. But then the follow up sync is fast.

There is still performance fruit on the table. I think I can squeeze a bit more speed out of jellyfin by doing prefetching pagination. And I haven't looked at db tuning yet.

beankylla commented 2 months ago

Hi

I had to activate verbose to see this it would not show up on info logs:

is this a known issue? and linked to the fact that not whole library syncs?

Is it caused by 1 song/album? is there any way to activate login to know on which entry this happens?

_2024-07-07 07:56:14.461 WARNING (MainThread) [music_assistant.music] Sync task for xx.com completed with errors Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/music.py", line 700, in run_sync await provider.sync_library(media_types) File "/usr/local/lib/python3.12/site-packages/music_assistant/server/models/music_provider.py", line 396, in sync_library async for prov_item in self._get_library_gen(media_type): File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/jellyfin/init.py", line 354, in get_library_tracks yield parse_track(self.logger, self.instance_id, self._client, track) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/jellyfin/parsers.py", line 170, in parse_track content = jellyfin_track[ITEM_KEY_MEDIA_STREAMS][0][ITEM_KEY_MEDIA_CODEC]


IndexError: list index out of range_
Jc2k commented 2 months ago

As I said before it's best to start a new issue now. Multiple different errors ended up getting lumped together in this issue making things hard to track.

It sounds like you have one of more tracks without a list of MediaStream. I don't know whether that's a configuration issue (maybe a permission thing), a problem with the file formats (there's another ticket about ogg for example) or something else.

beankylla commented 2 months ago

you're right my apologies. New issue opened!

https://github.com/music-assistant/hass-music-assistant/issues/2594