Skip to content

Commit

Permalink
Fix MBID Mapping Lookup element
Browse files Browse the repository at this point in the history
Remove year field no longer returned by the API and add missing artist_mbids field.
  • Loading branch information
amCap1712 committed Feb 12, 2024
1 parent 08ff8d9 commit 8de83c6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions troi/musicbrainz/mbid_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand All @@ -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:
Expand Down

0 comments on commit 8de83c6

Please sign in to comment.