]> kaliko git repositories - mpd-sima.git/blobdiff - sima/plugins/internal/random.py
Fixed previous commit, cannot apply shuffle on MetaContainer
[mpd-sima.git] / sima / plugins / internal / random.py
index 815824358b8975369ee97ee2bc8cec7bd0a6c1de..99e0599ff63f178a5fc37faf0b421771acd82dc8 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (c) 2013-2015, 2020 kaliko <kaliko@azylum.org>
+# Copyright (c) 2013-2015, 2020-2021 kaliko <kaliko@azylum.org>
 #
 #  This file is part of sima
 #
@@ -50,8 +50,8 @@ class Random(Plugin):
         """
         duration = self.main_conf.getint('sima', 'history_duration')
         tracks_from_db = self.sdb.get_history(duration=duration)
-        artists = [tr[0] for tr in tracks_from_db]
-        return set(artists)
+        artists = {tr[0] for tr in tracks_from_db}
+        return artists
 
     def filtered_artist(self, artist):
         """Filters artists:
@@ -63,7 +63,7 @@ class Random(Plugin):
         """
         if self.mode == 'sensible':
             if self.sdb.get_bl_artist(artist, add_not=True):
-                self.log.debug('Random: Blacklisted "%s"', artist)
+                self.log.debug('Random plugin: Blacklisted "%s"', artist)
                 return True
             if artist in self.get_played_artist():
                 return True
@@ -77,7 +77,7 @@ class Random(Plugin):
         self.candidates = []
         trks = []
         target = self.plugin_conf.getint('track_to_add')
-        artists = self.player.list('artist')
+        artists = self.player.list('artist', '( artist != "")')
         random.shuffle(artists)
         for art in artists:
             if self.filtered_artist(art):