feat: MBTarget exposes rgMbid + artistMbid from the resolver

This commit is contained in:
Jonathan
2026-07-11 16:54:11 +02:00
parent f421904c9b
commit 446d54f819
4 changed files with 18 additions and 1 deletions
+6 -1
View File
@@ -36,9 +36,12 @@ class MusicBrainzResolver:
canonical_album = rg.get("title", album)
canonical_artist = artist
artist_mbid = ""
credit = rg.get("artist-credit")
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
frd = rg.get("first-release-date", "") or ""
@@ -72,4 +75,6 @@ class MusicBrainzResolver:
total_duration_s=total_duration_s,
year=year,
tracklist=titles,
rg_mbid=rg.get("id", "") or "",
artist_mbid=artist_mbid,
)
+2
View File
@@ -9,6 +9,8 @@ class MBTarget:
total_duration_s: int | None = None
year: int | None = None
tracklist: tuple[str, ...] = ()
rg_mbid: str = ""
artist_mbid: str = ""
@dataclass(frozen=True)
+2
View File
@@ -16,3 +16,5 @@ def test_live_resolves_continuum():
assert target.track_count and target.track_count >= 10 # Continuum has 12 tracks
assert "continuum" in target.album.casefold()
assert target.year == 2006
assert target.rg_mbid # a real release-group MBID
assert target.artist_mbid # a real artist MBID
+8
View File
@@ -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"