Explorar o código

Fix lookup bug in track year

Colin Powell %!s(int64=2) %!d(string=hai) anos
pai
achega
ab88fcb9a7
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      vrobbler/apps/music/models.py

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

@@ -58,7 +58,13 @@ class Album(TimeStampedModel):
                     'artist-credit'
                 ][0]['artist']['id']
             if not self.year:
-                self.year = mb_data['release']['date'][0:4]
+                try:
+                    self.year = mb_data['release']['date'][0:4]
+                except KeyError:
+                    pass
+                except IndexError:
+                    pass
+
             self.save(update_fields=['musicbrainz_albumartist_id', 'year'])
 
             new_artist = Artist.objects.filter(