diff --git a/beetsplug/play.py b/beetsplug/play.py index c7d1403e0..e6611ad3f 100644 --- a/beetsplug/play.py +++ b/beetsplug/play.py @@ -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. diff --git a/docs/plugins/play.rst b/docs/plugins/play.rst index 54bf82649..08172c7c9 100644 --- a/docs/plugins/play.rst +++ b/docs/plugins/play.rst @@ -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.