Skip to content

Commit

Permalink
feat: improve mb search accuracy
Browse files Browse the repository at this point in the history
Adds new fields to musicbrainz search criteria to improve result accuracy.
  • Loading branch information
jtpavlock committed Oct 12, 2022
1 parent b2def8f commit 891b995
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 9 additions & 0 deletions moe/plugins/musicbrainz/mb_core.py
Expand Up @@ -132,6 +132,15 @@ def get_candidates(album: Album) -> list[CandidateAlbum]:
search_criteria["artist"] = album.artist
search_criteria["release"] = album.title
search_criteria["date"] = album.date.isoformat()
search_criteria["mediums"] = album.disc_total
if album.barcode:
search_criteria["barcode"] = album.barcode
if album.label:
search_criteria["label"] = album.label
if album.mb_album_id:
search_criteria["reid"] = album.mb_album_id
if album.media:
search_criteria["format"] = album.media

releases = musicbrainzngs.search_releases(limit=5, **search_criteria)

Expand Down
6 changes: 1 addition & 5 deletions tests/plugins/musicbrainz/test_mb_core.py
Expand Up @@ -129,11 +129,7 @@ def test_network(self, mb_config):
Since `get_matching_album` also calls `get_album_by_id`, this test serves as a
network test for both.
"""
album = album_factory(
config=mb_config,
artist="Kanye West",
title="My Beautiful Dark Twisted Fantasy",
)
album = mb_rsrc.album()

candidates = config.CONFIG.pm.hook.get_candidates(album=album)
mb_album = candidates[0][0].album
Expand Down

0 comments on commit 891b995

Please sign in to comment.