]> kaliko git repositories - mpd-sima.git/commitdiff
Improved client's find_track method with mbids
authorkaliko <kaliko@azylum.org>
Wed, 6 May 2015 15:23:33 +0000 (17:23 +0200)
committerkaliko <kaliko@azylum.org>
Wed, 6 May 2015 15:23:33 +0000 (17:23 +0200)
sima/client.py
sima/lib/webserv.py

index 66894a77a3516faeb3918a76a9943e4451d76825..499250fccd2d04c01ad96fab717a9b5a79b6c13d 100644 (file)
@@ -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
index 6a127f469f3116b74418fb804aa0499d98e8b2c3..dcc8707cb7a3f8dc43d3980e6149471bd6aca7a6 100644 (file)
@@ -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)