From 5a10f68f5d4b6bda63db74f205e6024d48c60e51 Mon Sep 17 00:00:00 2001 From: kaliko Date: Wed, 6 May 2015 17:23:33 +0200 Subject: [PATCH] Improved client's find_track method with mbids --- sima/client.py | 15 ++++++++------- sima/lib/webserv.py | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) 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) -- 2.39.2