Skip to content

Commit

Permalink
Subsonic: UNKNOWN_ARTIST handling (music-assistant#1464)
Browse files Browse the repository at this point in the history
  • Loading branch information
khers authored Jul 7, 2024
1 parent 24af8df commit 90e1d7c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions music_assistant/server/providers/opensubsonic/sonic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 90e1d7c

Please sign in to comment.