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.2k stars 44 forks source link

Youtube Music Provider show error on album link #2537

Open adonishi opened 4 days ago

adonishi commented 4 days ago

What version of Music Assistant has the issue?

2.1.0.b7

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

(standalone use)

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

The problem

When I try to open link with Album name in "Appears ON", Music Assistant shows error with "argument of type 'NoneType' is not iterable". so I turned on Server's log level to debug to see what the cause of this error.

2024-06-24 06:11:58.671 DEBUG (MainThread) [music_assistant.webserver] Handling command music/albums/get_album
2024-06-24 06:11:58.885 ERROR (MainThread) [music_assistant.webserver] Error handling message: CommandMessage(message_id=130, command='music/albums/get_album', args={'item_id': 'MPREb_4OgZ7Jjmv0k', 'provider_instance_id_or_domain': 'ytmusic--zYwpsrPw'})
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/webserver.py", line 351, in _run_handler
    result = await result
             ^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/albums.py", line 78, in get
    album = await super().get(
            ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 294, in get
    details = await self.get_provider_item(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/controllers/media/base.py", line 558, in get_provider_item
    if item := await provider.get_item(self.media_type, item_id):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/models/music_provider.py", line 278, in get_item
    return await self.get_album(prov_item_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/ytmusic/__init__.py", line 298, in get_album
    return await self._parse_album(album_obj=album_obj, album_id=prov_album_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/music_assistant/server/providers/ytmusic/__init__.py", line 645, in _parse_album
    album.metadata.description = unquote(album_obj["description"])
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/urllib/parse.py", line 684, in unquote
    if '%' not in string:
       ^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

it seems urllib.parse's unquote() called with None as argument. ytmusic's code is...

        if "description" in album_obj:
            album.metadata.description = unquote(album_obj["description"])

https://github.com/music-assistant/server/blob/main/music_assistant/server/providers/ytmusic/__init__.py#L623-L624

so I think, album_obj has "description" entry, but content of "description" is None.

How to reproduce

スクリーンショット 2024-06-25 15 59 11 スクリーンショット 2024-06-25 15 59 19

Music Providers

Youtube Music

Player Providers

UPnP/DLNA Player provider

Full log output

log.txt

Additional information

No response

What version of Home Assistant Core are your running

None

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Linux