feat: MBTarget exposes rgMbid + artistMbid from the resolver
This commit is contained in:
@@ -36,9 +36,12 @@ class MusicBrainzResolver:
|
|||||||
|
|
||||||
canonical_album = rg.get("title", album)
|
canonical_album = rg.get("title", album)
|
||||||
canonical_artist = artist
|
canonical_artist = artist
|
||||||
|
artist_mbid = ""
|
||||||
credit = rg.get("artist-credit")
|
credit = rg.get("artist-credit")
|
||||||
if isinstance(credit, list) and credit and isinstance(credit[0], dict):
|
if isinstance(credit, list) and credit and isinstance(credit[0], dict):
|
||||||
canonical_artist = (credit[0].get("artist") or {}).get("name", artist)
|
_artist = credit[0].get("artist") or {}
|
||||||
|
canonical_artist = _artist.get("name", artist)
|
||||||
|
artist_mbid = _artist.get("id", "") or ""
|
||||||
|
|
||||||
year = None
|
year = None
|
||||||
frd = rg.get("first-release-date", "") or ""
|
frd = rg.get("first-release-date", "") or ""
|
||||||
@@ -72,4 +75,6 @@ class MusicBrainzResolver:
|
|||||||
total_duration_s=total_duration_s,
|
total_duration_s=total_duration_s,
|
||||||
year=year,
|
year=year,
|
||||||
tracklist=titles,
|
tracklist=titles,
|
||||||
|
rg_mbid=rg.get("id", "") or "",
|
||||||
|
artist_mbid=artist_mbid,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ class MBTarget:
|
|||||||
total_duration_s: int | None = None
|
total_duration_s: int | None = None
|
||||||
year: int | None = None
|
year: int | None = None
|
||||||
tracklist: tuple[str, ...] = ()
|
tracklist: tuple[str, ...] = ()
|
||||||
|
rg_mbid: str = ""
|
||||||
|
artist_mbid: str = ""
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|||||||
@@ -16,3 +16,5 @@ def test_live_resolves_continuum():
|
|||||||
assert target.track_count and target.track_count >= 10 # Continuum has 12 tracks
|
assert target.track_count and target.track_count >= 10 # Continuum has 12 tracks
|
||||||
assert "continuum" in target.album.casefold()
|
assert "continuum" in target.album.casefold()
|
||||||
assert target.year == 2006
|
assert target.year == 2006
|
||||||
|
assert target.rg_mbid # a real release-group MBID
|
||||||
|
assert target.artist_mbid # a real artist MBID
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
from lyra_worker.types import MBTarget
|
||||||
|
|
||||||
|
|
||||||
|
def test_mbtarget_has_rg_and_artist_mbid_defaults():
|
||||||
|
t = MBTarget(artist="A", album="B")
|
||||||
|
assert t.rg_mbid == "" and t.artist_mbid == ""
|
||||||
|
t2 = MBTarget(artist="A", album="B", rg_mbid="rg1", artist_mbid="a1")
|
||||||
|
assert t2.rg_mbid == "rg1" and t2.artist_mbid == "a1"
|
||||||
Reference in New Issue
Block a user