From: kaliko Date: Wed, 6 May 2015 15:23:33 +0000 (+0200) Subject: Improved client's find_track method with mbids X-Git-Tag: 0.14.0~9 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=5a10f68f5d4b6bda63db74f205e6024d48c60e51;p=mpd-sima.git Improved client's find_track method with mbids --- diff --git a/sima/client.py b/sima/client.py index 66894a7..499250f 100644 --- a/sima/client.py +++ b/sima/client.py @@ -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 diff --git a/sima/lib/webserv.py b/sima/lib/webserv.py index 6a127f4..dcc8707 100644 --- a/sima/lib/webserv.py +++ b/sima/lib/webserv.py @@ -368,7 +368,7 @@ class WebService(Plugin): artists = self.get_local_similar_artists() nbtracks_target = self.plugin_conf.getint('track_to_add') for artist in artists: - self.log.debug('Trying to find titles to add for "{}"'.format( + self.log.debug('Trying to find titles to add for "{!r}"'.format( artist)) found = self.player.find_track(artist) random.shuffle(found)