[placeholder]
key = Value
+#[crop]
+# type: integer
+# description: How many played tracks to keep in the playlist.
+# Allow to maintain a fixed length playlist.
+# Leave commented to keep all tracks
+#consume = 10
+
[RandomFallback]
# random falvour :
# * pure: complete ramdom choice among all tracks available in the player media library
history_duration = 8
##
-## CONSUME
-# type: integer
-# description: How many played tracks to keep in the playlist.
-# Allow to maintain a fixed length playlist.
-# set to 0 to keep all played tracks.
-#
-consume = 0
-##
-
## USER_DB # NOT IMPLEMENTED #
# type: boolean
# description: Load user database to find similar artists
Crop playlist on next track
kinda MPD's consume
"""
+ def __init__(self, daemon):
+ super().__init__(daemon)
+ self.target = None
+ if not self.plugin_conf:
+ return
+ target = self.plugin_conf.get('consume', None)
+ if not target:
+ return
+ if not target.isdigit():
+ self.log.warning('Bad value for consume, '
+ 'expecting an integer, not "{}"'.format(target))
+ else:
+ self.target = int(target)
def callback_playlist(self):
+ if not self.target:
+ return
player = self._Plugin__daemon.player
- target_lengh = 10
- while player.currentsong().pos > target_lengh:
+ while player.currentsong().pos > self.target:
self.log.debug('cropping playlist')
player.remove()