Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Commit

Permalink
Modify library search to support renemaed session search
Browse files Browse the repository at this point in the history
  • Loading branch information
amayernc committed May 18, 2016
1 parent 5ed4907 commit 43b495a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mopidy_gmusic/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ def search(self, query=None, uris=None, exact=False):

lib_tracks, lib_artists, lib_albums = self._search_library(query, uris)

if query and self.all_access:
aa_tracks, aa_artists, aa_albums = self._search_all_access(
if query:
aa_tracks, aa_artists, aa_albums = self._search(
query, uris)
for aa_artist in aa_artists:
lib_artists.add(aa_artist)
Expand Down Expand Up @@ -324,7 +324,7 @@ def _find_exact(self, query=None, uris=None):
artists=lib_artists,
albums=lib_albums)

def _search_all_access(self, query=None, uris=None):
def _search(self, query=None, uris=None):
for (field, values) in query.iteritems():
if not hasattr(values, '__iter__'):
values = [values]
Expand All @@ -334,9 +334,9 @@ def _search_all_access(self, query=None, uris=None):
if field in [
'track_name', 'album', 'artist', 'albumartist', 'any']:
logger.info(
'Searching Google Play Music All Access for: %s',
'Searching Google Play Music for: %s',
values[0])
res = self.backend.session.search_all_access(
res = self.backend.session.search(
values[0], max_results=50)
if res is None:
return [], [], []
Expand Down
4 changes: 4 additions & 0 deletions tests/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,7 @@ def test_lookup_invalid_track(self):
refs = self.backend.library.lookup('gmusic:track:invalid_uri')
# tests should be unable to fetch any content :(
self.assertEqual(refs, [])

def test_search(self):
refs = self.backend.library.search({'artist': ['abba']})
self.assertIsNotNone(refs)

0 comments on commit 43b495a

Please sign in to comment.