From 90e1d7c3e8044f2af8ab0a9a9174d7d3a8f73e4e Mon Sep 17 00:00:00 2001 From: Eric Munson Date: Sun, 7 Jul 2024 18:51:29 -0400 Subject: [PATCH] Subsonic: UNKNOWN_ARTIST handling (#1464) --- .../server/providers/opensubsonic/sonic_provider.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/music_assistant/server/providers/opensubsonic/sonic_provider.py b/music_assistant/server/providers/opensubsonic/sonic_provider.py index 28de9cebe..810ff2012 100644 --- a/music_assistant/server/providers/opensubsonic/sonic_provider.py +++ b/music_assistant/server/providers/opensubsonic/sonic_provider.py @@ -320,6 +320,10 @@ def _parse_album(self, sonic_album: SonicAlbum, sonic_info: SonicAlbumInfo = Non ) ) else: + logging.getLogger("libopensonic").info( + f"Unable to find an artist ID for album '{sonic_album.name}' with " + f"ID '{sonic_album.id}'." + ) album.artists.append( Artist( item_id=UNKNOWN_ARTIST_ID, @@ -400,6 +404,10 @@ def _parse_track(self, sonic_song: SonicSong) -> Track: track.artists.append(self._get_item_mapping(MediaType.ARTIST, entry.id, entry.name)) if not track.artists: + logging.getLogger("libopensonic").info( + f"Unable to find artist ID for track '{sonic_song.title}' with " + f"ID '{sonic_song.id}'." + ) track.artists.append( Artist( item_id=UNKNOWN_ARTIST_ID, @@ -681,6 +689,10 @@ async def get_playlist_tracks( async def get_artist_toptracks(self, prov_artist_id: str) -> list[Track]: """Get the top listed tracks for a specified artist.""" + # We have seen top tracks requested for the UNKNOWN_ARTIST ID, protect against that + if prov_artist_id == UNKNOWN_ARTIST_ID: + return [] + try: sonic_artist: SonicArtist = await self._run_async(self._conn.getArtist, prov_artist_id) except DataNotFoundError as e: