Skip to content

Commit

Permalink
Merge branch 'server/api-cleanup' of github.com:Arthi-chaud/Meelo int…
Browse files Browse the repository at this point in the history
…o server/api-cleanup
  • Loading branch information
Arthi-chaud committed Jan 8, 2025
2 parents e8c2701 + 1d8296c commit 9db000c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion matcher/matcher/matcher/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ def match_and_post_album(album_id: int, album_name: str):
context = Context.get()
album = context.client.get_album(album_id)
(dto, release_date, album_type, genres) = match_album(
album_id, album_name, album.artist.name, album.type
album_id,
album_name,
album.artist.name if album.artist else None,
album.type,
)
# We only care about the new album type if the previous type is Studio
album_type = (
Expand Down
2 changes: 1 addition & 1 deletion matcher/matcher/models/api/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Artist(DataClassJsonMixin):
@dataclass
class Album(DataClassJsonMixin):
name: str
artist: Artist
artist: Optional[Artist] = None
type: AlbumType = AlbumType.OTHER
release_date: Optional[str] = None

Expand Down
2 changes: 2 additions & 0 deletions matcher/matcher/providers/musicbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ def _get_album_type(self, album: Any) -> AlbumType | None:
return AlbumType.STUDIO
if "remix" in raw_types:
return AlbumType.REMIXES
if "live" in raw_types:
return AlbumType.LIVE
if "compilation" in raw_types:
return AlbumType.COMPILATION
if "dj-mix" in raw_types:
Expand Down
4 changes: 4 additions & 0 deletions matcher/tests/providers/musicbrainz.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ def test_get_album_release_date_month_only(self):

def test_get_album_type(self):
scenarios: List[Tuple[str, AlbumType]] = [
# Madonna - I'm Going to tell you a secret
("876da970-473b-3a01-9aea-79d1fa6b053a", AlbumType.LIVE),
# Madonna - Finally Enough Love
("7316f52d-7421-43af-b9e8-02e1cab17153", AlbumType.REMIXES),
# Massive Attack - No Protection
("54bd7d44-86e1-3e3c-82e0-10febdedcbda", AlbumType.REMIXES),
# Girls Aloud - Mixed Up
Expand Down

0 comments on commit 9db000c

Please sign in to comment.