From: awhiemstra Date: Thu, 23 Jan 2025 22:20:34 +0000 (+0100) Subject: Fix: Use Deezer record_type to set the album type of Deezer albums (#1905) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=70ac37937b6be22b03b0b687e9d0ec20141169de;p=music-assistant-server.git Fix: Use Deezer record_type to set the album type of Deezer albums (#1905) --- diff --git a/music_assistant/providers/deezer/__init__.py b/music_assistant/providers/deezer/__init__.py index 181f3f54..fcf12d12 100644 --- a/music_assistant/providers/deezer/__init__.py +++ b/music_assistant/providers/deezer/__init__.py @@ -573,7 +573,7 @@ class DeezerProvider(MusicProvider): def parse_album(self, album: deezer.Album) -> Album: """Parse the deezer-python album to a Music Assistant album.""" return Album( - album_type=AlbumType(album.type), + album_type=self.get_album_type(album), item_id=str(album.id), provider=self.lookup_key, name=album.title, @@ -688,6 +688,23 @@ class DeezerProvider(MusicProvider): return track.title_short return track.title + def get_album_type(self, album: deezer.Album) -> AlbumType: + """Read and convert the Deezer album type.""" + if not hasattr(album, "record_type"): + return AlbumType.UNKNOWN + + match album.record_type: + case "album": + return AlbumType.ALBUM + case "single": + return AlbumType.SINGLE + case "ep": + return AlbumType.EP + case "compile": + return AlbumType.COMPILATION + case _: + return AlbumType.UNKNOWN + ### SEARCH AND PARSE FUNCTIONS ### async def search_and_parse_tracks( self, query: str, user_country: str, limit: int = 20