From: kaliko Date: Sun, 15 Feb 2015 11:53:09 +0000 (+0100) Subject: crop: Allow negative value for consume to disable plugin X-Git-Tag: 0.14.0~11 X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=ea112d4630c7fc4e33d28d2ad77475a097e5f9a7;p=mpd-sima.git crop: Allow negative value for consume to disable plugin --- diff --git a/data/man/mpd_sima.cfg.5 b/data/man/mpd_sima.cfg.5 index faf4003..cd7cf01 100644 --- a/data/man/mpd_sima.cfg.5 +++ b/data/man/mpd_sima.cfg.5 @@ -2,12 +2,12 @@ .\" Title: mpd_sima.cfg .\" Author: Jack Kaliko .\" Generator: DocBook XSL Stylesheets v1.78.1 -.\" Date: 02/08/2015 +.\" Date: 02/15/2015 .\" Manual: mpd-sima 0.14.0 User Manual .\" Source: mpd-sima .\" Language: English .\" -.TH "MPD_SIMA\&.CFG" "5" "02/08/2015" "mpd-sima" "mpd-sima 0.14.0 User Manual" +.TH "MPD_SIMA\&.CFG" "5" "02/15/2015" "mpd-sima" "mpd-sima 0.14.0 User Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- @@ -220,9 +220,9 @@ crop plugin\*(Aqs configuration: .RS 4 .RE .PP -\fBconsume=\fR\fI0\fR +\fBconsume=\fR\fI10\fR .RS 4 -How many played tracks to keep in the queue\&. Allows you to maintain a fixed length queue\&. Set to 0 to keep all played tracks\&. +How many played tracks to keep in the queue\&. Allows you to maintain a fixed length queue\&. Set to some negative integer to keep all played tracks\&. .RE .PP \fBpriority=\fR\fI10\fR diff --git a/data/man/mpd_sima.cfg.5.xml b/data/man/mpd_sima.cfg.5.xml index 71189d4..d097909 100644 --- a/data/man/mpd_sima.cfg.5.xml +++ b/data/man/mpd_sima.cfg.5.xml @@ -252,11 +252,11 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/ - 0 + 10 How many played tracks to keep in the queue. Allows you to maintain a fixed length queue. - Set to 0 to keep all played tracks. + Set to some negative integer to keep all played tracks. diff --git a/doc/examples/all_settings.cfg b/doc/examples/all_settings.cfg index e8470be..4904c0e 100644 --- a/doc/examples/all_settings.cfg +++ b/doc/examples/all_settings.cfg @@ -115,6 +115,7 @@ musicbrainzid = True # default: 10 # description: How many played tracks to keep in the playlist. # Allow to maintain a fixed length playlist. +# Set a negative value to disable cropping (or remove plugin from sima/internal) #consume = 10 [random] diff --git a/sima/plugins/internal/crop.py b/sima/plugins/internal/crop.py index 1f8ab2c..fd0656c 100644 --- a/sima/plugins/internal/crop.py +++ b/sima/plugins/internal/crop.py @@ -38,14 +38,19 @@ class Crop(Plugin): self.target = None if not self.plugin_conf: return - target = self.plugin_conf.get('consume', None) + target = self.plugin_conf.get('consume') if not target: return - if not target.isdigit(): + try: + if int(target) < 0: + self.log.info('Negative value for consume, not cropping') + return + except ValueError: self.log.warning('Bad value for consume, ' 'expecting an integer, not "{}"'.format(target)) else: self.target = int(target) + self.log.debug('Cropping at 15') def callback_next_song(self): if not self.target: