Spotify albums may be None

This commit is contained in:
Stein Magnus Jodal 2011-05-25 21:08:34 +02:00
parent b992277e7f
commit fc9875bf3d

View File

@ -21,7 +21,7 @@ class SpotifyTranslator(object):
@classmethod
def to_mopidy_album(cls, spotify_album):
if not spotify_album.is_loaded():
if spotify_album is None or not spotify_album.is_loaded():
return Album(name=u'[loading...]')
# TODO pyspotify got much more data on albums than this
return Album(name=spotify_album.name().decode(ENCODING))
@ -31,7 +31,8 @@ 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 dt.MINYEAR <= int(spotify_track.album().year()) <= dt.MAXYEAR:
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)
else:
date = None