Fix bad lookup of artists

This commit is contained in:
2023-04-06 14:09:00 -04:00
parent be6b3c5e2e
commit 2896225826
2 changed files with 12 additions and 7 deletions

View File

@ -26,9 +26,10 @@ def get_or_create_artist(name: str, mbid: str = None) -> Artist:
name = re.split("&", name, flags=re.IGNORECASE)[0].strip()
artist_dict = lookup_artist_from_mb(name)
mbid = mbid or artist_dict["id"]
mbid = mbid or artist_dict.get("id", None)
artist = Artist.objects.filter(musicbrainz_id=mbid).first()
if mbid:
artist = Artist.objects.filter(musicbrainz_id=mbid).first()
if not artist:
artist = Artist.objects.create(name=name, musicbrainz_id=mbid)
artist.fix_metadata()