Skip to content

Commit

Permalink
Fix: Use Deezer record_type to set the album type of Deezer albums (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
awhiemstra authored Jan 23, 2025
1 parent fb589de commit 70ac379
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion music_assistant/providers/deezer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def parse_artist(self, artist: deezer.Artist) -> Artist:
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,
Expand Down Expand Up @@ -688,6 +688,23 @@ def get_short_title(self, track: deezer.Track):
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
Expand Down

0 comments on commit 70ac379

Please sign in to comment.