Fix bug in audiodb scrape path

This commit is contained in:
2023-03-02 15:45:15 -05:00
parent fb6110c71d
commit 7dd7f369d8
2 changed files with 7 additions and 2 deletions

View File

@ -129,7 +129,9 @@ class Album(TimeStampedModel):
return self.artists.first()
def scrape_theaudiodb(self) -> None:
artist = self.primary_artist.name
artist = "Various Artists"
if self.primary_artist:
artist = self.primary_artist.name
album_data = lookup_album_from_tadb(self.name, artist)
if not album_data.get('theaudiodb_id'):
logger.info(f"No data for {self} found in TheAudioDB")

View File

@ -58,13 +58,16 @@ def lookup_album_from_tadb(name: str, artist: str) -> dict:
album_info['theaudiodb_mood'] = album.get('strMood')
album_info['theaudiodb_speed'] = album.get('strSpeed')
album_info['theaudiodb_theme'] = album.get('strTheme')
album_info['theaudiodb_year_released'] = album.get('intYearReleased')
album_info['allmusic_id'] = album.get('strAllMusicID')
album_info['wikipedia_slug'] = album.get('strWikipediaID')
album_info['discogs_id'] = album.get('strDiscogsID')
album_info['wikidata_id'] = album.get('strWikidataID')
album_info['rateyourmusic_id'] = album.get('strRateYourMusicID')
if album.get('intYearReleased'):
album_info['theaudiodb_year_released'] = float(
album.get('intYearReleased')
)
if album.get('intScore'):
album_info['theaudiodb_score'] = float(album.get('intScore'))
if album.get('intScoreVotes'):