diff --git a/mopidy/backends/__init__.py b/mopidy/backends/__init__.py index 692185ca..55da11c2 100644 --- a/mopidy/backends/__init__.py +++ b/mopidy/backends/__init__.py @@ -204,7 +204,7 @@ class BaseLibraryController(object): """ Search the library for tracks where ``type`` contains ``query``. - :param type: 'track', 'artist', 'album', or 'uri' + :param type: 'track', 'artist', 'album', 'uri', and 'any' :type type: string :param query: the search query :type query: string diff --git a/mopidy/backends/despotify.py b/mopidy/backends/despotify.py index 06159db0..e8a78752 100644 --- a/mopidy/backends/despotify.py +++ b/mopidy/backends/despotify.py @@ -41,9 +41,15 @@ class DespotifyLibraryController(BaseLibraryController): return self.backend.translate.to_mopidy_track(track) def search(self, type, what): - query = u'%s:%s' % (type, what) + if type == u'track': + type = u'title' + if type == u'any': + query = what + else: + query = u'%s:%s' % (type, what) result = self.backend.spotify.search(query.encode(ENCODING)) - if result is None: + if (result is None or result.playlist.tracks[0].get_uri() == + 'spotify:track:0000000000000000000000'): return Playlist() return self.backend.translate.to_mopidy_playlist(result.playlist) diff --git a/mopidy/backends/libspotify.py b/mopidy/backends/libspotify.py index bfe2e4db..8a2218b8 100644 --- a/mopidy/backends/libspotify.py +++ b/mopidy/backends/libspotify.py @@ -48,7 +48,10 @@ class LibspotifyLibraryController(BaseLibraryController): # FIXME When searching while playing music, this is really slow, like # 12-14s between querying and getting results. self._search_results_received.clear() - query = u'%s:%s' % (type, what) + if type is u'any': + query = what + else: + query = u'%s:%s' % (type, what) def callback(results, userdata): logger.debug(u'Search results received') self._search_results = results