Add support for 'any' type to search in all backends. Search works in GMPC :-D
This commit is contained in:
parent
290f3adc14
commit
e0b65b9603
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user