mirror of
https://github.com/beetbox/beets.git
synced 2025-12-15 04:55:10 +01:00
Added optional argument for play-plugin
* New config key "play -> optargs"
* New Subcommand argument "-o", "--optargs"
* Set position using "{}" within "play -> command"-string
This commit is contained in:
parent
1f72184533
commit
0a995c218a
1 changed files with 11 additions and 1 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue