jellyfin / mopidy-jellyfin

Jellyfin Extension for Mopidy
https://jellyfin.org
Apache License 2.0
93 stars 16 forks source link

Un-handled exception when starting mopidy #107

Open dassystem opened 3 years ago

dassystem commented 3 years ago

Hi,

when starting mopidy on a fresh install with enabled jellyfin on my Raspberry Pi4 (arm64) I get an error:

ERROR    2021-05-13 17:21:17,128 [24104:MainThread] mopidy.commands
  Got un-handled exception from JellyfinBackend
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/mopidy/commands.py", line 241, in _actor_error_handling
    yield
  File "/usr/local/lib/python3.7/dist-packages/mopidy/commands.py", line 406, in start_backends
    config=config, audio=audio
  File "/usr/local/lib/python3.7/dist-packages/pykka/_actor.py", line 86, in start
    obj = cls(*args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/backend.py", line 27, in __init__
    self.playlists = JellyfinPlaylistsProvider(backend=self)
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/playlists.py", line 17, in __init__
    self.refresh()
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/playlists.py", line 80, in refresh
    playlists.update(self.favorites())
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/playlists.py", line 144, in favorites
    favorite_playlists = self.backend.remote.get_favorites()
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py", line 336, in get_favorites
    playlists['Artists'].extend(self.lookup_artist(artist_id))
  File "/usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py", line 890, in lookup_artist
    album_dict = OrderedDict(sorted(album_dict.items()))
TypeError: '<' not supported between instances of 'NoneType' and 'str'

My ~/.config/mopidy/mopidy.conf:

[jellyfin]
enabled = true
username = MYNAME
password = MYPW
hostname = http://192.168.178.77:8096
max_bitrate = 320

jellyfin web shows successful login:

MYNAME ist online von pi4
heute um 17:21
IP-Adresse: 192.168.178.77

Mopidy starts sucessfully with not loaded plugin.

I'm totally unsure what I might be missing here. And if it is an configuration issue, the exception should be handled with a readable message. I appreciate any help.

mcarlton00 commented 3 years ago

I've never seen this issue before, so I doubt it's a config issue. Based on the traceback, when creating local playlists based off your marked favorites in the server it found something that made it unhappy. Could you share what types of items you have Favorited in the server? I'll try to replicate it on my side.

dassystem commented 3 years ago

I have some artists marked as my favorites:

Artists:

Maybe an encoding issue cased by umlauts?

After removing (all of) them from favorites the plugin works in mopidy!

mcarlton00 commented 3 years ago

I'm guessing it's probably the special characters causing havoc. Odd that it's just failing instead of throwing unicode errors like I would expect though. I'll need to look into it, but that gives me something to work off of at least.

mcarlton00 commented 3 years ago

I tricked my library into thinking I had artists named Die Höchste Eisenbahn and Ostzonensuppenwürfelmachenkrebs thinking it was the special characters causing issues, but it seems to be working fine on my side.

If you want to go a level deeper in debugging, we can add some extra logging that tells us what it's failing on.

If so, edit /usr/local/lib/python3.7/dist-packages/mopidy_jellyfin/remote.py.

Now when you start mopidy, it will spit out what it's trying to load. In theory, the last entry shown will be what's breaking it. Then you can load up a browser with https://jellyfin.example.com/web/index.html#!/details?serverId=d08ab95bec674b89a030e13341290e22&id={YOUR ARTIST ID HERE}

Looking at the code, it's possible that it's an album or track name that's causing the errors, not an artist name. That would be more difficult to track down, but getting the artist would be a good first step.

dassystem commented 3 years ago

Adding the logging I found out that Artist "Kettcar" (my artist id 0303cd515ad98dd2f4504179a50e146c) is causing troubles. Besides several albums I had two mp3s in a "misc" folder that I got from compilations. Removing them from my media folder results in mopidy starting without errors.

So I tried to have a closer look into those files:

$ ffprobe Kettcar\ -\ Genauer\ Betrachtet.mp3 2>&1 | grep -A90 'Metadata:'
  Metadata:
    title           : Genauer betrachtet
    artist          : Kettcar
  Duration: 00:03:14.32, start: 0.000000, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s

and

$ ffprobe Kettcar\ -\ Hauptsache\ Glauben.mp3 2>&1 | grep -A90 'Metadata:' 
  Metadata:
    title           : Hauptsache Glauben
    artist          : Kettcar
  Duration: 00:03:35.80, start: 0.000000, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s

Yes, they lack some metadata, but they should be intact files.

dassystem commented 3 years ago

After renaming and adding more metadata:

ffprobe Kettcar\ -\ Du\ und\ wieviel\ von\ deinen\ Freunden\ -\ CD\ 02\ -\ 09\ -\ Genauer\ betrachtet\ \(EP\ Version\).mp3 2>&1 | grep -A90 'Metadata:' 
  Metadata:
    TMED            : CD
    track           : 09/09
    TORY            : 2002
    TSO2            : Kettcar
    artist-sort     : Kettcar
    SCRIPT          : Latn
    ARTISTS         : Kettcar
    ASIN            : B009I48Y70
    originalyear    : 2002
    publisher       : Grand Hotel van Cleef
    BARCODE         : 4047179726726
    CATALOGNUMBER   : GHvC 070
    MusicBrainz Album Type: album
    MusicBrainz Album Status: official
    MusicBrainz Album Release Country: DE
    Acoustid Id     : 125afcda-4976-4943-8403-4f7b29836bcc
    MusicBrainz Album Id: 9487dab6-a5df-4fce-b37e-b5d811eebafd
    MusicBrainz Artist Id: 315fa94f-3bb5-43db-a28e-406a83e9805c
    MusicBrainz Album Artist Id: 315fa94f-3bb5-43db-a28e-406a83e9805c
    MusicBrainz Release Group Id: 1c1e202d-a9d6-3aed-b451-5ca1cd24ffd5
    MusicBrainz Release Track Id: c8f78c92-c3d1-3136-8cbf-ec47b92d9efb
    title           : Genauer betrachtet (EP Version)
    artist          : Kettcar
    album_artist    : Kettcar
    album           : Du und wieviel von deinen Freunden
    disc            : 02/02
    date            : 2012-11-02
  Duration: 00:03:14.32, start: 0.000000, bitrate: 128 kb/s

Mopidy-jellyfin now starts without errors. But why was that an issue before?

mcarlton00 commented 3 years ago

Very interesting. Going back to the first error, the end result was TypeError: '<' not supported between instances of 'NoneType' and 'str'. So apparently one of the values that it was trying to use to compare items to each other was one of those empty tags (the NoneType). I can't say I've ever seen that before, but since it's inside of the sorted comparison and not code that I actually wrote, I'm not sure if there would be a "fix" for it. I suppose I should be able to catch the error more gracefully, possibly even override the values with something to make it not error.

Good detective work, I never would have thought of missing tags as the cause for something like this. I'll have to clear a few files of mine out and see if I can break it myself now.

GetLifty commented 1 year ago

Was there ever a fix for this? Ive started getting the same error now and I also have some files without metadata. Well, I actually have quite alot of files without metadata, so removal isnt an option for me.

Edit: Turns out this is definitely an issue with artists with no metadata. I reformatted a few songs that had weird characters or missing artists and it had no effect, but removing a single favourited artist with no metadata instantly fixed it...