]> kaliko git repositories - mpd-sima.git/commitdiff
crop: Allow negative value for consume to disable plugin
authorkaliko <kaliko@azylum.org>
Sun, 15 Feb 2015 11:53:09 +0000 (12:53 +0100)
committerkaliko <kaliko@azylum.org>
Sun, 15 Feb 2015 12:06:29 +0000 (13:06 +0100)
data/man/mpd_sima.cfg.5
data/man/mpd_sima.cfg.5.xml
doc/examples/all_settings.cfg
sima/plugins/internal/crop.py

index faf40036f417b56767df4539774b41301402d1be..cd7cf0183cd548b128415c9d370af915fd64813f 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: mpd_sima.cfg
 .\"    Author: Jack Kaliko <kaliko@azylum.org>
 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\"      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
index 71189d4c52b5ef078906c771c77dbf1a7f646928..d097909507355e585669eae0e1fee2f8a343a2a5 100644 (file)
@@ -252,11 +252,11 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
                     <term><option>[crop]</option></term>
                 </varlistentry>
                 <varlistentry> <!-- crop.consume -->
-                    <term><option>consume=</option><replaceable>0</replaceable></term>
+                    <term><option>consume=</option><replaceable>10</replaceable></term>
                     <listitem>
                         <para>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.
                         </para>
                     </listitem>
                 </varlistentry>
index e8470be73dc790cbd14b161ee8f0bc0432190dff..4904c0ebae7442cc132edd128be4d9e8c9e83ed8 100644 (file)
@@ -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]
index 1f8ab2c1936f9d39cd0c898d7a40e0c1973859f5..fd0656c8542395a819be38512e33364c5e903da3 100644 (file)
@@ -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: