Despotify: Catch and log SpytifyError

This commit is contained in:
Stein Magnus Jodal 2010-07-31 23:13:45 +02:00
parent b4c80fdc2f
commit c3a228fbfd
2 changed files with 30 additions and 9 deletions

View File

@ -31,6 +31,10 @@ We got an updated :doc:`release roadmap <development/roadmap>`!
- Having multiple identical tracks in a playlist is now working properly.
(CPID refactoring)
- Despotify backend:
- Catch and log :exc:`spytify.SpytifyError`. (Fixes: :issue:`11`)
- Libspotify backend:
- Fix choppy playback using the Libspotify backend by using blocking ALSA

View File

@ -76,20 +76,36 @@ class DespotifyLibraryController(BaseLibraryController):
class DespotifyPlaybackController(BasePlaybackController):
def _pause(self):
self.backend.spotify.pause()
return True
try:
self.backend.spotify.pause()
return True
except spytify.SpytifyError as e:
logger.error(e)
return False
def _play(self, track):
self.backend.spotify.play(self.backend.spotify.lookup(track.uri))
return True
try:
self.backend.spotify.play(self.backend.spotify.lookup(track.uri))
return True
except spytify.SpytifyError as e:
logger.error(e)
return False
def _resume(self):
self.backend.spotify.resume()
return True
try:
self.backend.spotify.resume()
return True
except spytify.SpytifyError as e:
logger.error(e)
return False
def _stop(self):
self.backend.spotify.stop()
return True
try:
self.backend.spotify.stop()
return True
except spytify.SpytifyError as e:
logger.error(e)
return False
class DespotifyStoredPlaylistsController(BaseStoredPlaylistsController):
@ -146,7 +162,8 @@ class DespotifyTranslator(object):
return Playlist(
uri=spotify_playlist.get_uri(),
name=spotify_playlist.name.decode(ENCODING),
tracks=filter(None, [cls.to_mopidy_track(t) for t in spotify_playlist.tracks]),
tracks=filter(None,
[cls.to_mopidy_track(t) for t in spotify_playlist.tracks]),
)