From ddc7e07ec62ca2190dc1ab3f80d042f7562cca6e Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Wed, 28 Apr 2010 12:24:07 +0200 Subject: [PATCH] libspotify: Handle SpotifyError (e.g. 'The track cannot be played') in _play() --- mopidy/backends/libspotify.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mopidy/backends/libspotify.py b/mopidy/backends/libspotify.py index d89f9400..edffa3af 100644 --- a/mopidy/backends/libspotify.py +++ b/mopidy/backends/libspotify.py @@ -4,7 +4,7 @@ import os import multiprocessing import threading -from spotify import Link +from spotify import Link, SpotifyError from spotify.manager import SpotifySessionManager from spotify.alsahelper import AlsaController @@ -94,10 +94,14 @@ class LibspotifyPlaybackController(BasePlaybackController): self.stop() if track.uri is None: return False - self.backend.spotify.session.load( - Link.from_string(track.uri).as_track()) - self.backend.spotify.session.play(1) - return True + try: + self.backend.spotify.session.load( + Link.from_string(track.uri).as_track()) + self.backend.spotify.session.play(1) + return True + except SpotifyError as e: + logger.warning('Play %s failed: %s', track.uri, e) + return False def _resume(self): # TODO