X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Fclient.py;h=f3d1614ad6b6672093024feca685604c262d9fba;hb=d6dadb1d86ae2e9082d45f1f5fda2f8152ae2f8a;hp=0bfc8826be36ca0027df7b6df3af3598456527f7;hpb=70bf86ca3f65a550436cdc70326cb8601f24e5a6;p=mpd-sima.git diff --git a/sima/client.py b/sima/client.py index 0bfc882..f3d1614 100644 --- a/sima/client.py +++ b/sima/client.py @@ -141,25 +141,24 @@ class PlayerClient(Player): self._cache['artists'] = frozenset(self._client.list('artist')) @blacklist(track=True) - def _find_track(self, artist, title): - #return getattr(self, 'find')('artist', artist, 'title', title) - if title: - return self.find('artist', artist, 'title', title) - return self.find('artist', artist) - def find_track(self, artist, title=None): - tracks = list() - if isinstance(artist, Artist): - for name in artist.names: - tracks.extend(self._find_track(name, title=title)) - else: - tracks.extend(self._find_track(artist,title=title)) - return tracks + 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)) + return list(tracks) - @blacklist(track=True) def fuzzy_find_track(self, artist, title): # Retrieve all tracks from artist - all_tracks = self.find('artist', artist) + all_tracks = self.find_track(artist, title) # Get all titles (filter missing titles set to 'None') all_artist_titles = frozenset([tr.title for tr in all_tracks if tr.title is not None]) @@ -197,8 +196,9 @@ class PlayerClient(Player): album containing at least a single track for artist """ albums = [] - for name in artist.aliases: - self.log.debug('Searching album for {}'.format(name)) + for name in artist.names: + if len(artist.names) > 1: + self.log.debug('Searching album for aliase: "{}"'.format(name)) kwalbart = {'albumartist':name, 'artist':name} for album in self.list('album', 'albumartist', artist): if album and album not in albums: @@ -324,6 +324,8 @@ class PlayerClient(Player): self.log.warning('Use of MusicBrainzIdentifier is set but MPD is ' 'not providing related metadata') self.log.info(self._client.tagtypes()) + self.log.warning('Disabling MusicBrainzIdentifier') + Artist.use_mbid = False else: self.log.warning('Use of MusicBrainzIdentifier disabled!') self.log.info('Consider using MusicBrainzIdentifier for your music library')