play: Insert arguments anywhere (#1532)

This commit is contained in:
Adrian Sampson 2015-08-16 09:23:09 -07:00
parent ecf677ae41
commit 759c79c426
2 changed files with 18 additions and 1 deletions

View file

@ -25,6 +25,10 @@ from beets import util
from os.path import relpath
from tempfile import NamedTemporaryFile
# Indicate where arguments should be inserted into the command string.
# If this is missing, they're placed at the end.
ARGS_MARKER = '$args'
class PlayPlugin(BeetsPlugin):
@ -63,7 +67,10 @@ class PlayPlugin(BeetsPlugin):
# Add optional arguments to the player command.
if opts.args:
command_str = "{} {}".format(command_str, opts.args)
if ARGS_MARKER in command_str:
command_str = command_str.replace(ARGS_MARKER, opts.args)
else:
command_str = "{} {}".format(command_str, opts.args)
# Perform search by album and add folders rather than tracks to
# playlist.

View file

@ -66,3 +66,13 @@ to get beets to execute this command::
mplayer -quiet -shuffle /path/to/playlist.m3u
instead of the default.
If you need to insert arguments somewhere other than the end of the
``command`` string, use ``$args`` to indicate where to insert them. For
example::
play:
command: mpv $args --playlist
indicates that you need to insert extra arguments before specifying the
playlist.