jellyfin / mopidy-jellyfin

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

Unhandled Exception from JellyfinBackend: "TypeError: 'NoneType' object is not iterable" during startup #144

Closed felix920506 closed 2 months ago

felix920506 commented 3 months ago

After a fresh install of mopidy on macos 13.1 I get this error during startup

Mopidy config Jellyfin section

[jellyfin]
enabled = true
username = user
#user_id = 
# password = 
token = *****
hostname = https://example.com/jellyfin
libraries = "動漫、遊戲音樂", "音樂"
#albumartistsort = 
#port = 
#client_cert = 
#client_key = 
#album_format = 
#max_bitrate = 
#watched_status = false

Mopidy output in console

INFO     2024-03-15 12:11:00,783 [83452:MainThread] mopidy.__main__
  Starting Mopidy 2.7.4-13378-g780fbbc65e
INFO     2024-03-15 12:11:00,899 [83452:MainThread] mopidy.config
  Loading config from builtin defaults
INFO     2024-03-15 12:11:00,899 [83452:MainThread] mopidy.config
  Loading config from file:///Users/user/.config/mopidy/mopidy.conf
INFO     2024-03-15 12:11:00,899 [83452:MainThread] mopidy.config
  Loading config from command line options
INFO     2024-03-15 12:11:00,943 [83452:MainThread] mopidy.__main__
  Enabled extensions: file, http, softwaremixer, jellyfin, stream, iris, m3u
INFO     2024-03-15 12:11:00,943 [83452:MainThread] mopidy.__main__
  Disabled extensions: none
INFO     2024-03-15 12:11:00,974 [83452:MainThread] mopidy.commands
  Starting Mopidy mixer: SoftwareMixer
INFO     2024-03-15 12:11:00,975 [83452:MainThread] mopidy.commands
  Starting Mopidy audio
INFO     2024-03-15 12:11:00,975 [83452:MainThread] mopidy.commands
  Starting Mopidy backends: FileBackend, M3UBackend, StreamBackend, JellyfinBackend
INFO     2024-03-15 12:11:00,981 [83452:Audio-2 (_actor_loop)] mopidy.audio.actor
  Audio output set to "autoaudiosink"
ERROR    2024-03-15 12:11:01,829 [83452:MainThread] mopidy.commands
  Got un-handled exception from JellyfinBackend
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.12/site-packages/mopidy/commands.py", line 248, in _actor_error_handling
    yield
  File "/opt/homebrew/lib/python3.12/site-packages/mopidy/commands.py", line 412, in start_backends
    backend = backend_class.start(
              ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/pykka/_actor.py", line 117, in start
    obj = cls(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/mopidy_jellyfin/backend.py", line 27, in __init__
    self.playlists = JellyfinPlaylistsProvider(backend=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/mopidy_jellyfin/playlists.py", line 17, in __init__
    self.refresh()
  File "/opt/homebrew/lib/python3.12/site-packages/mopidy_jellyfin/playlists.py", line 59, in refresh
    raw_playlists = self.backend.remote.get_playlists()
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.12/site-packages/mopidy_jellyfin/remote.py", line 198, in get_playlists
    library_id = [
                 ^
TypeError: 'NoneType' object is not iterable
INFO     2024-03-15 12:11:01,832 [83452:MainThread] mopidy.commands
  Starting Mopidy core
INFO     2024-03-15 12:11:01,836 [83452:MainThread] mopidy.commands
  Starting Mopidy frontends: HttpFrontend, IrisFrontend, EventMonitorFrontend
INFO     2024-03-15 12:11:01,837 [83452:HttpFrontend-8 (_actor_loop)] mopidy.http.actor
  HTTP server running at [::ffff:127.0.0.1]:6680
INFO     2024-03-15 12:11:01,837 [83452:IrisFrontend-9 (_actor_loop)] mopidy_iris.core
  Starting Iris 3.69.3
INFO     2024-03-15 12:11:02,463 [83452:MainThread] mopidy.commands
  Starting GLib mainloop
CptMinato commented 2 months ago

I was having the exact same issue and was able to fix it by setting username, user_id and token. I found the user_id best by using jellyfin-web and being in the profile settings of that user either as admin or user itself.

When I didn't set libraries, Everything but Albums and Tracks worked, otherwise:

https://github.com/jellyfin/mopidy-jellyfin/blob/30a09c3c4018ca38749f313ad7dc35eb70f4908f/README.rst?plain=1#L48

Weirdly enough Tracks is still empty for me.

Maybe the Readme should have the Optional for user_id and token removed. As without token:

Exception: No authentication token found

and with token but without user_id the aforementioned:

TypeError: 'NoneType' object is not iterable
mcarlton00 commented 2 months ago

This issue has nothing to do with authentication method. This is because the released version was specifically looking for a "playlists" library that the user may or may not have created yet, and was fixed in #136. Version 1.0.5 has now been released that should include this fix