]> kaliko git repositories - mpd-sima.git/blobdiff - sima/client.py
Add lastfm/album mode
[mpd-sima.git] / sima / client.py
index 929f66281fd7489cc2d001a75efa5755e3ffe138..80c16e530875a2b6fd68fcff717568bbb339e96d 100644 (file)
@@ -22,7 +22,6 @@ except ImportError as err:
 from .lib.player import Player
 from .lib.track import Track
 from .lib.simastr import SimaStr
-from .utils.leven import levenshtein_ratio
 
 
 class PlayerError(Exception):
@@ -151,21 +150,14 @@ class PlayerClient(Player):
                 matching_artists.append(fuzz_art)
                 self.log.debug('"%s" matches "%s".' % (fuzz_art, artist))
                 return matching_artists
-            # Proceed with levenshtein and SimaStr
-            leven = levenshtein_ratio(artist.stripped.lower(),
-                    SimaStr(fuzz_art).stripped.lower())
-            # SimaStr string __eq__, not regular string comparison here
+            # SimaStr string __eq__ (not regular string comparison here)
             if artist == fuzz_art:
                 matching_artists.append(fuzz_art)
                 self.log.info('"%s" quite probably matches "%s" (SimaStr)' %
                               (fuzz_art, artist))
-            elif leven >= 0.82:  # PARAM
-                matching_artists.append(fuzz_art)
-                self.log.debug('FZZZ: "%s" should match "%s" (lr=%1.3f)' %
-                               (fuzz_art, artist, leven))
             else:
-                self.log.debug('FZZZ: "%s" does not match "%s" (lr=%1.3f)' %
-                               (fuzz_art, artist, leven))
+                self.log.debug('FZZZ: "%s" does not match "%s"' %
+                               (fuzz_art, artist))
         return matching_artists
 
     def find_album(self, artist, album):
@@ -178,6 +170,16 @@ class PlayerClient(Player):
             return alb_art_search
         return self.find('artist', artist, 'album', album)
 
+    def find_albums(self, artist):
+        """
+        Special wrapper around album search:
+        Album lookup is made through AlbumArtist/Album instead of Artist/Album
+        """
+        alb_art_search = self.list('album', 'albumartist', artist,)
+        if alb_art_search:
+            return alb_art_search
+        return self.list('album', 'artist', artist)
+
     def monitor(self):
         curr = self.current
         try: