Check if album is loaded before use

This commit is contained in:
Stein Magnus Jodal 2011-12-28 23:56:52 +01:00
parent 4cc7b87669
commit 088f3e8505

View File

@ -31,9 +31,10 @@ class SpotifyTranslator(object):
uri = str(Link.from_track(spotify_track, 0))
if not spotify_track.is_loaded():
return Track(uri=uri, name=u'[loading...]')
if (spotify_track.album() is not None and
dt.MINYEAR <= int(spotify_track.album().year()) <= dt.MAXYEAR):
date = dt.date(spotify_track.album().year(), 1, 1)
spotify_album = spotify_track.album()
if (spotify_album is not None and spotify_album.is_loaded()
and dt.MINYEAR <= int(spotify_album.year()) <= dt.MAXYEAR):
date = dt.date(spotify_album.year(), 1, 1)
else:
date = None
return Track(