Allow forcing updates from TADB

This commit is contained in:
2023-06-21 11:18:06 -04:00
parent e517327ce3
commit ad2f28c214
2 changed files with 25 additions and 7 deletions

View File

@ -104,10 +104,18 @@ class Artist(TimeStampedModel):
self.bandcamp_id = slug
self.save(update_fields=["bandcamp_id"])
def fix_metadata(self):
tadb_info = lookup_artist_from_tadb(self.name)
def fix_metadata(self, force_update=False):
tadb_info = {}
if self.theaudiodb_id and force_update:
tadb_info = lookup_artist_from_tadb(self.theaudiodb_id)
if not self.theaudiodb_id or (force_update and not tadb_info):
tadb_info = lookup_artist_from_tadb(self.name)
if not tadb_info:
logger.warn(f"No response from TADB for artist {self.name}")
logger.warn(
f"No response from TADB for artist {self.name}, try force_update=True"
)
return
self.biography = tadb_info["biography"]