]> kaliko git repositories - mpd-sima.git/blobdiff - sima/plugins/internal/crop.py
crop: Allow negative value for consume to disable plugin
[mpd-sima.git] / sima / plugins / internal / crop.py
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: