From 8de83c6673620a53d6bd0a5d217ec4b79a240290 Mon Sep 17 00:00:00 2001 From: Kartik Ohri Date: Mon, 12 Feb 2024 16:03:26 +0530 Subject: [PATCH 1/2] Fix MBID Mapping Lookup element Remove year field no longer returned by the API and add missing artist_mbids field. --- troi/musicbrainz/mbid_mapping.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/troi/musicbrainz/mbid_mapping.py b/troi/musicbrainz/mbid_mapping.py index a8c64504..c75856c6 100644 --- a/troi/musicbrainz/mbid_mapping.py +++ b/troi/musicbrainz/mbid_mapping.py @@ -31,8 +31,7 @@ def read(self, inputs): params = [] for r in inputs[0]: if r.artist is not None and r.name is not None: - params.append({"[artist_credit_name]": r.artist.name, - "[recording_name]": r.name}) + params.append({"[artist_credit_name]": r.artist.name, "[recording_name]": r.name}) if not params: return [] @@ -51,22 +50,28 @@ def read(self, inputs): continue if r.mbid: - r.add_note("recording mbid %s overwritten by mbid_lookup" % (r.mbid)) + r.add_note("recording mbid %s overwritten by mbid_lookup" % (r.mbid,)) r.mbid = row['recording_mbid'] r.name = row['recording_name'] - r.year = row['year'] if r.artist is None: - r.artist = Artist(artist_credit_id=row['artist_credit_id'], name=row['artist_credit_name']) + r.artist = Artist( + artist_credit_id=row['artist_credit_id'], + name=row['artist_credit_name'], + mbids=row['artist_mbids'] + ) else: if r.artist.artist_credit_id: - r.artist.add_note("artist_credit_id %d overwritten by mbid_lookup" % (r.artist.artist_credit_id)) + r.artist.add_note("artist_credit_id %d overwritten by mbid_lookup" % (r.artist.artist_credit_id,)) + if r.artist.mbids: + r.artist.add_note("mbids %s overwritten by mbid_lookup" % (r.artist.mbids,)) r.artist.artist_credit_id = row['artist_credit_id'] r.artist.name = row['artist_credit_name'] + r.artist.mbids = row['artist_mbids'] if r.release: if r.release.mbid: - r.release.add_note("mbid %d overwritten by mbid_lookup" % (r.release.mbid)) + r.release.add_note("mbid %d overwritten by mbid_lookup" % (r.release.mbid,)) r.release.mbid = row['release_mbid'] r.release.name = row['release_name'] else: From 064ae1b6e9f542ad5440eee7bfb2113dc05f9585 Mon Sep 17 00:00:00 2001 From: Kartik Ohri Date: Mon, 12 Feb 2024 16:07:49 +0530 Subject: [PATCH 2/2] Fix tests --- tests/musicbrainz/test_mbid_mapping.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/musicbrainz/test_mbid_mapping.py b/tests/musicbrainz/test_mbid_mapping.py index d508bdfb..5dc84a9e 100644 --- a/tests/musicbrainz/test_mbid_mapping.py +++ b/tests/musicbrainz/test_mbid_mapping.py @@ -16,7 +16,7 @@ "recording_name": "Trigger Hippie", "release_mbid": "9db51cd6-38f6-3b42-8ad5-559963d68f35", "release_name": "Who Can You Trust?", - "year": 1996 + "artist_mbids": ["067102ea-9519-4622-9077-57ca4164cfbb"] } ] @@ -51,12 +51,11 @@ def test_read(self, req): assert len(entities) == 1 assert entities[0].artist.artist_credit_id == 963 assert entities[0].artist.name == "Morcheeba" + assert entities[0].artist.mbids == ["067102ea-9519-4622-9077-57ca4164cfbb"] assert entities[0].release.mbid == "9db51cd6-38f6-3b42-8ad5-559963d68f35" assert entities[0].release.name == "Who Can You Trust?" assert entities[0].mbid == "97e69767-5d34-4c97-b36a-f3b2b1ef9dae" assert entities[0].name == "Trigger Hippie" - assert entities[0].year == 1996 - @unittest.mock.patch('requests.post') def test_read_remove_unmatched(self, req):