From 0a995c218afe033124fdff198ec67ae487a7575c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20R=C3=BCmpelein?= Date: Thu, 2 Jul 2015 20:14:46 +0200 Subject: [PATCH] Added optional argument for play-plugin * New config key "play -> optargs" * New Subcommand argument "-o", "--optargs" * Set position using "{}" within "play -> command"-string --- beetsplug/play.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/beetsplug/play.py b/beetsplug/play.py index 65d5b91ec..1c8a062c9 100644 --- a/beetsplug/play.py +++ b/beetsplug/play.py @@ -35,6 +35,7 @@ class PlayPlugin(BeetsPlugin): 'command': None, 'use_folders': False, 'relative_to': None, + 'optional_args': None, }) def commands(self): @@ -43,19 +44,28 @@ class PlayPlugin(BeetsPlugin): help='send music to a player as a playlist' ) play_command.parser.add_album_option() + play_command.parser.add_option('-o','--optargs',action='store_true', + help='Insert additional arguments into command string') play_command.func = self.play_music return [play_command] def play_music(self, lib, opts, args): """Execute query, create temporary playlist and execute player - command passing that playlist. + command passing that playlist, at request insert optional arguments. """ command_str = config['play']['command'].get() use_folders = config['play']['use_folders'].get(bool) relative_to = config['play']['relative_to'].get() + optional_args = config['play']['optional_args'].get() if relative_to: relative_to = util.normpath(relative_to) + # Prepare command strings wirh optional args + if opts.optargs: + command_str=command_str.format(optional_args or '') + else: + command_str=command_str.format('') + # Perform search by album and add folders rather than tracks to # playlist. if opts.album: