]> kaliko git repositories - mpd-sima.git/blobdiff - sima/lib/webserv.py
Some cleanup in log, get messages more uniform across plugins
[mpd-sima.git] / sima / lib / webserv.py
index 4b3e2989666db4c782a893dc378b4fc319ae0205..96d63afa000e5abde869054fd247f502b616c4b4 100644 (file)
@@ -214,9 +214,7 @@ class WebService(AdvancedPlugin):
             # get them reorg to pick up best element
             ret_extra = self.get_reorg_artists_list(ret_extra)
             # tries to pickup less artist from extra art
-            if len(ret) < 4:
-                ret_extra = MetaContainer(ret_extra)
-            else:
+            if len(ret) > 4:
                 ret_extra = MetaContainer(ret_extra[:max(4, len(ret))//2])
             if ret_extra:
                 self.log.debug('extra found in library: %s',
@@ -245,7 +243,7 @@ class WebService(AdvancedPlugin):
         # Move around similars items to get in unplayed|not recently played
         # artist first.
         self.log.info('Got %d artists in library', len(ret))
-        candidates = self.get_reorg_artists_list(list(ret))
+        candidates = self.get_reorg_artists_list(ret)
         if candidates:
             self.log.info(' / '.join(map(str, candidates)))
         return candidates
@@ -266,7 +264,9 @@ class WebService(AdvancedPlugin):
         nb_album_add = 0
         target_album_to_add = self.plugin_conf.getint('album_to_add')
         for artist in artists:
-            album = self.album_candidate(artist)
+            album = self.album_candidate(artist, unplayed=True)
+            if not album:
+                continue
             nb_album_add += 1
             candidates = self.player.find_tracks(album)
             if self.plugin_conf.getboolean('shuffle_album'):
@@ -313,10 +313,10 @@ class WebService(AdvancedPlugin):
         for artist in artists:
             self.log.debug('Trying to find titles to add for "%r"', artist)
             found = self.player.find_tracks(artist)
-            random.shuffle(found)
             if not found:
                 self.log.debug('Found nothing to queue for %s', artist)
                 continue
+            random.shuffle(found)
             # find tracks not in history for artist
             track_candidate = self.filter_track(found)
             if track_candidate:
@@ -327,7 +327,7 @@ class WebService(AdvancedPlugin):
             self.log.debug('Found no tracks to queue!')
             return
         for track in self.to_add:
-            self.log.info('%s candidates: %s', track, self.ws.name)
+            self.log.info('%s plugin chose: %s', self.ws.name, trk)
 
     def _album(self):
         """Get albums for album queue mode
@@ -356,6 +356,8 @@ class WebService(AdvancedPlugin):
         msg = ' '.join(['{0}: {1:>3d}'.format(k, v) for
                         k, v in sorted(self.ws.stats.items())])
         self.log.debug('http stats: ' + msg)
+        if not self.to_add:
+            self.log.info('%s plugin found nothing to queue', self.ws.name)
         candidates = self.to_add
         self.to_add = list()
         if self.plugin_conf.get('queue_mode') != 'album':