]> kaliko git repositories - mpd-sima.git/commitdiff
Update random plugin
authorkaliko <kaliko@azylum.org>
Sun, 20 Dec 2020 17:00:34 +0000 (18:00 +0100)
committerkaliko <kaliko@azylum.org>
Sun, 20 Dec 2020 17:00:34 +0000 (18:00 +0100)
sima/plugins/internal/random.py

index 148138b0d9aa99bda28c46a1084eed6bc48311b7..815824358b8975369ee97ee2bc8cec7bd0a6c1de 100644 (file)
@@ -37,7 +37,6 @@ class Random(Plugin):
 
     def __init__(self, daemon):
         super().__init__(daemon)
-        self.daemon = daemon
         self.mode = self.plugin_conf.get('flavour', None)
         if self.mode not in ['pure', 'sensible']:
             self.log.warning('Bad value for flavour, '
@@ -49,8 +48,8 @@ class Random(Plugin):
     def get_played_artist(self,):
         """Constructs list of already played artists.
         """
-        duration = self.daemon.config.getint('sima', 'history_duration')
-        tracks_from_db = self.daemon.sdb.get_history(duration=duration)
+        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)
 
@@ -63,7 +62,7 @@ class Random(Plugin):
          * not blacklisted
         """
         if self.mode == 'sensible':
-            if self.daemon.sdb.get_bl_artist(artist, add_not=True):
+            if self.sdb.get_bl_artist(artist, add_not=True):
                 self.log.debug('Random: Blacklisted "%s"', artist)
                 return True
             if artist in self.get_played_artist():
@@ -88,7 +87,7 @@ class Random(Plugin):
             if trks:
                 trk = random.choice(trks)
                 self.candidates.append(trk)
-                self.log.info('Random candidate (%s): %s', self.mode, trk)
+                self.log.info('Random plugin chose (%s): %s', self.mode, trk)
             if len(self.candidates) >= target:
                 break
         return self.candidates