spotify: Fix crash when a playlist is added (fixes #387)

This commit is contained in:
Stein Magnus Jodal 2013-04-28 10:04:57 +02:00
parent d1ca5da470
commit 44cf8a0099
2 changed files with 12 additions and 1 deletions

View File

@ -86,6 +86,9 @@ one new.
- Add support for starred playlists, both your own and those owned by other
users. (Fixes: :issue:`326`)
- Fix crash when a new playlist is added by another Spotify client. (Fixes:
:issue:`387`)
**MPD frontend**
- Playlists with identical names are now handled properly by the MPD frontend

View File

@ -1,9 +1,13 @@
from __future__ import unicode_literals
import logging
import spotify
from mopidy.models import Artist, Album, Track, Playlist
logger = logging.getLogger('mopidy.backends.spotify')
artist_cache = {}
album_cache = {}
@ -66,7 +70,11 @@ def to_mopidy_track(spotify_track, bitrate=None):
def to_mopidy_playlist(spotify_playlist, bitrate=None, username=None):
if spotify_playlist is None or spotify_playlist.type() != 'playlist':
return
uri = str(spotify.Link.from_playlist(spotify_playlist))
try:
uri = str(spotify.Link.from_playlist(spotify_playlist))
except spotify.SpotifyError as e:
logger.debug('Spotify playlist translation error: %s', e)
return
if not spotify_playlist.is_loaded():
return Playlist(uri=uri, name='[loading...]')
name = spotify_playlist.name()