1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2013, 2014 Jack Kaliko <kaliko@azylum.org>
4 # This file is part of sima
6 # sima is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # sima is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with sima. If not, see <http://www.gnu.org/licenses/>.
23 # standard library import
24 #from select import select
26 # third parties components
29 from ...lib.plugin import Plugin
33 Crop playlist on next track
36 def __init__(self, daemon):
37 super().__init__(daemon)
39 if not self.plugin_conf:
41 target = self.plugin_conf.get('consume', None)
44 if not target.isdigit():
45 self.log.warning('Bad value for consume, '
46 'expecting an integer, not "{}"'.format(target))
48 self.target = int(target)
50 def callback_next_song(self):
53 player = self._Plugin__daemon.player
54 if player.currentsong().pos > self.target:
55 self.log.debug('cropping playlist')
56 while player.currentsong().pos > self.target:
61 # vim: ai ts=4 sw=4 sts=4 expandtab