]> kaliko git repositories - mpd-sima.git/blobdiff - sima/lib/webserv.py
Improved documentation
[mpd-sima.git] / sima / lib / webserv.py
index 9eb76bafcc79b87f912b89ef5ef11de6dc8cf51b..3a484c2fde86cfbe5915124a56f4185cd028abcc 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (c) 2009-2014 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2009-2015 Jack Kaliko <kaliko@azylum.org>
 #
 #  This file is part of sima
 #
@@ -243,6 +243,8 @@ class WebService(Plugin):
         if ret:
             self.log.debug('regular found in library: {}'.format(
                            ' / '.join(map(str, ret))))
+        else:
+            self.log.debug('Got nothing similar from library!')
         ret_extra = None
         if len(self.history) >= 2:
             if self.plugin_conf.getint('depth') > 1:
@@ -250,8 +252,11 @@ class WebService(Plugin):
         if ret_extra:
             # get them reorg to pick up best element
             ret_extra = self._get_artists_list_reorg(ret_extra)
-            # pickup half the number of ret artist
-            ret_extra = MetaContainer(ret_extra[:max(4, len(ret))//2])
+            # tries to pickup less artist from extra art
+            if len(ret) < 4:
+                ret_extra = MetaContainer(ret_extra)
+            else:
+                ret_extra = MetaContainer(ret_extra[:max(4, len(ret))//2])
             if ret_extra:
                 self.log.debug('extra found in library: {}'.format(
                                ' / '.join(map(str, ret_extra))))
@@ -338,7 +343,6 @@ class WebService(Plugin):
         self.to_add = list()
         nbtracks_target = self.plugin_conf.getint('track_to_add')
         for artist in artists:
-            artist = Artist(name=artist)
             if len(self.to_add) == nbtracks_target:
                 return True
             self.log.info('Looking for a top track for {0}'.format(artist))