Explorar el Código

Fix bug in audiodb scrape path

Colin Powell hace 2 años
padre
commit
7dd7f369d8
Se han modificado 2 ficheros con 7 adiciones y 2 borrados
  1. 3 1
      vrobbler/apps/music/models.py
  2. 4 1
      vrobbler/apps/scrobbles/theaudiodb.py

+ 3 - 1
vrobbler/apps/music/models.py

@@ -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")

+ 4 - 1
vrobbler/apps/scrobbles/theaudiodb.py

@@ -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'):