X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fclient.py;h=499250fccd2d04c01ad96fab717a9b5a79b6c13d;hb=4a9e3fe83539718e1609e250869d5e42216c4204;hp=926e2952acc5a9c177d8b622f01bb4d620935217;hpb=23309f235879380a5ef7db3a51bda4d12e31902e;p=mpd-sima.git diff --git a/sima/client.py b/sima/client.py index 926e295..499250f 100644 --- a/sima/client.py +++ b/sima/client.py @@ -159,8 +159,8 @@ class PlayerClient(Player): else: self.log.info('Player: Initialising cache!') self._cache = { - 'artists': None, - 'nombid_artists': None, + 'artists': frozenset(), + 'nombid_artists': frozenset(), } self._cache['artists'] = frozenset(self._execute('list', ['artist'])) if Artist.use_mbid: @@ -169,17 +169,18 @@ class PlayerClient(Player): @blacklist(track=True) def find_track(self, artist, title=None): tracks = set() - for name in artist.names: - if title: - tracks |= set(self.find('artist', name, 'title', title)) - else: - tracks |= set(self.find('artist', name)) if artist.mbid: if title: - tracks |= set(self.find('musicbrainz_artistid', artist.mbid)) - else: tracks |= set(self.find('musicbrainz_artistid', artist.mbid, 'title', title)) + else: + tracks |= set(self.find('musicbrainz_artistid', artist.mbid)) + else: + for name in artist.names: + if title: + tracks |= set(self.find('artist', name, 'title', title)) + else: + tracks |= set(self.find('artist', name)) return list(tracks) @bl_artist @@ -206,9 +207,9 @@ class PlayerClient(Player): if artist.mbid: # we already performed a lookup on artists with mbid set # search through remaining artists - artists = self._cache.get('nombid_artists', []) + artists = self._cache.get('nombid_artists') else: - artists = self._cache.get('artists', []) + artists = self._cache.get('artists') match = get_close_matches(artist.name, artists, 50, 0.73) if not match and not found: return @@ -336,7 +337,7 @@ class PlayerClient(Player): @property def artists(self): - return self._cache.get('artists') | self._cache.get('nombid_artists') + return self._cache.get('artists') @property def state(self):