]> kaliko git repositories - mpd-sima.git/commitdiff
Implement "single_album" filter
authorkaliko <efrim@azylum.org>
Sun, 8 Dec 2013 15:34:55 +0000 (16:34 +0100)
committerkaliko <efrim@azylum.org>
Sun, 8 Dec 2013 15:34:55 +0000 (16:34 +0100)
doc/examples/all_settings.cfg
launch
sima/core.py
sima/lib/plugin.py
sima/plugins/internal/lastfm.py
vinstall.sh

index 9e2d87cff5557a1cf0653efb256c8453551d3838..c0581a097ece8c14b663e451e22c7b5132401ad2 100644 (file)
@@ -173,11 +173,11 @@ dynamic = 10
 # description: TBD
 depth = 1
 
-## SINGLE_ALBUM # NOT IMPLEMENTED #
+## SINGLE_ALBUM
 # type: boolean
 # scope: "track" and "top" queue modes
 # description: Prevent from queueing a track from the same album (for instance with OST).
-single_album = true
+single_album = false
 
 ## TRACK_TO_ADD
 # type: integer
diff --git a/launch b/launch
index 3e88542efee5b6e7d4049479c5940e7800816129..43fc0bc797dfc2cb84ab9cb38436432bf12a2ec7 100755 (executable)
--- a/launch
+++ b/launch
@@ -86,7 +86,7 @@ def main():
     logger.info('Starting...')
     sima = core.Sima(config)
 
-    # core plugins
+    # required core plugins
     sima.register_plugin(History)
     sima.register_plugin(MpdOptions)
 
@@ -104,7 +104,7 @@ def main():
         sima.foreground()
     except KeyboardInterrupt:
         logger.info('Caught KeyboardInterrupt, stopping')
-        #sima.shutdown()
+        sima.shutdown()
 
 
 def run():
index f6703ca8317b0c204fce89e8234cd139518bd38d..d705a6257841455058e599df2d364a2a764e0cf8 100644 (file)
@@ -114,7 +114,6 @@ class Sima(Daemon):
         self.log.info('The way is shut, it was made by those who are dead. '
                       'And the dead keep it…')
         self.log.info('bye...')
-        sys.exit(0)
 
     def run(self):
         """
index cea4448346749c582e91944623712978ff5f595b..0e80ae582f865751c8f9b43a39bd5b63d53e311e 100644 (file)
@@ -38,7 +38,7 @@ class Plugin():
         conf = self.__daemon.config
         for sec in conf.sections():
             if sec.lower() == self.__class__.__name__.lower():
-                self.plugin_conf = dict(conf.items(sec))
+                self.plugin_conf = conf[sec]
         #if self.plugin_conf:
         #    self.log.debug('Got config for {0}: {1}'.format(self,
         #                                                    self.plugin_conf))
index bff015b5550d151b855c533e541ee73e0aecf682..c5a772f5b763552961854bda1787a90a9aad0867 100644 (file)
@@ -142,6 +142,13 @@ class Lastfm(Plugin):
             if self.sdb.get_bl_album(trk, add_not=True):
                 self.log.info('Blacklisted album: {0}: '.format(trk))
                 continue
+            # Should use albumartist heuristic as well
+            if self.plugin_conf.getboolean('single_album'):
+                if (trk.album == self.player.current.album or
+                    trk.album in [trk.alb for trk in self.to_add]):
+                    self.log.debug('Found unplayed track ' +
+                               'but from an album already queued: %s' % (trk))
+                    continue
             candidate.append(trk)
         if not candidate:
             self.log.debug('Unable to find title to add' +
index e249ae8db3588c09bdee2ea9af361fdfe70d1cd0..a6cb6b44801271196ad62c52be49d80bc32034b3 100755 (executable)
@@ -13,7 +13,7 @@ DEBUG=${DEBUG:-"0"}     #  Set to 1 in order to enable DEBUG message.
                         ## Only error message will be printed with DEBUG="0"
 
 
-PY3=${PY3:-$(which python3.3)}
+PY3=${PY3:-$(which python3)}
 
 # Test virtualenv presence
 [ -x "$(which virtualenv)" ] || { echo "Cannot find virtualenv executable!"; exit 1; }