]> kaliko git repositories - mpd-sima.git/blobdiff - sima/plugins/internal/crop.py
Some better logging messages to debug uniq bug
[mpd-sima.git] / sima / plugins / internal / crop.py
index 1f8ab2c1936f9d39cd0c898d7a40e0c1973859f5..7efb5b5491d7e40927ab87a025093967e5b0cd37 100644 (file)
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright (c) 2013, 2014 Jack Kaliko <kaliko@azylum.org>
+# Copyright (c) 2013, 2014, 2015 Jack Kaliko <kaliko@azylum.org>
 #
 #  This file is part of sima
 #
@@ -38,18 +38,26 @@ 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))
+                             'expecting an integer, not "%s"', target)
         else:
             self.target = int(target)
+            self.log.debug('Cropping at 15')
 
     def callback_next_song(self):
         if not self.target:
             return
+        if not self._Plugin__daemon.enabled:
+            self.log.debug('Queueing disabled, not cropping')
+            return False
         player = self._Plugin__daemon.player
         if player.currentsong().pos > self.target:
             self.log.debug('cropping playlist')