libspotify: Handle SpotifyError (e.g. 'The track cannot be played') in _play()
This commit is contained in:
parent
441362028c
commit
ddc7e07ec6
@ -4,7 +4,7 @@ import os
|
|||||||
import multiprocessing
|
import multiprocessing
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from spotify import Link
|
from spotify import Link, SpotifyError
|
||||||
from spotify.manager import SpotifySessionManager
|
from spotify.manager import SpotifySessionManager
|
||||||
from spotify.alsahelper import AlsaController
|
from spotify.alsahelper import AlsaController
|
||||||
|
|
||||||
@ -94,10 +94,14 @@ class LibspotifyPlaybackController(BasePlaybackController):
|
|||||||
self.stop()
|
self.stop()
|
||||||
if track.uri is None:
|
if track.uri is None:
|
||||||
return False
|
return False
|
||||||
self.backend.spotify.session.load(
|
try:
|
||||||
Link.from_string(track.uri).as_track())
|
self.backend.spotify.session.load(
|
||||||
self.backend.spotify.session.play(1)
|
Link.from_string(track.uri).as_track())
|
||||||
return True
|
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):
|
def _resume(self):
|
||||||
# TODO
|
# TODO
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user