From: kaliko Date: Sun, 8 Dec 2013 15:34:55 +0000 (+0100) Subject: Implement "single_album" filter X-Git-Tag: mpd-sima/0.12.0pr2~14 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=2d4111ef3e3eb3811df95b139aac66b61c3ad5bf;p=mpd-sima.git Implement "single_album" filter --- diff --git a/doc/examples/all_settings.cfg b/doc/examples/all_settings.cfg index 9e2d87c..c0581a0 100644 --- a/doc/examples/all_settings.cfg +++ b/doc/examples/all_settings.cfg @@ -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 3e88542..43fc0bc 100755 --- 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(): diff --git a/sima/core.py b/sima/core.py index f6703ca..d705a62 100644 --- a/sima/core.py +++ b/sima/core.py @@ -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): """ diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py index cea4448..0e80ae5 100644 --- a/sima/lib/plugin.py +++ b/sima/lib/plugin.py @@ -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)) diff --git a/sima/plugins/internal/lastfm.py b/sima/plugins/internal/lastfm.py index bff015b..c5a772f 100644 --- a/sima/plugins/internal/lastfm.py +++ b/sima/plugins/internal/lastfm.py @@ -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' + diff --git a/vinstall.sh b/vinstall.sh index e249ae8..a6cb6b4 100755 --- a/vinstall.sh +++ b/vinstall.sh @@ -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; }