From ebba3a3d14c822257b1d192bf66b0f8b96bd9fa2 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Sat, 21 Mar 2015 23:16:05 +0100 Subject: [PATCH] backend: Allow None as return from translate_uri() --- mopidy/backend.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mopidy/backend.py b/mopidy/backend.py index b41b92c0..ffefe047 100644 --- a/mopidy/backend.py +++ b/mopidy/backend.py @@ -203,13 +203,16 @@ class PlaybackProvider(object): """ Convert custom URI scheme to real playable uri. + *MAY be reimplemented by subclass.* + This is very likely the *only* thing you need to override as a backend - author. Typically this is where you convert any Mopidy specific URIs - to real URIs and then return it. + author. Typically this is where you convert any Mopidy specific URI + to a real URI and then return it. If you can't convert the URI just + return :class:`None`. :param uri: the URI to translate. :type uri: string - :rtype: string + :rtype: string or :class:`None` if the URI could not be translated. """ return uri @@ -230,7 +233,10 @@ class PlaybackProvider(object): :type track: :class:`mopidy.models.Track` :rtype: :class:`True` if successful, else :class:`False` """ - self.audio.set_uri(self.translate_uri(track.uri)).get() + uri = self.translate_uri(track.uri) + if not uri: + return False + self.audio.set_uri(uri).get() return True def resume(self):