Original bug report by @404NetworkError here:
streamlink/streamlink-twitch-gui#464
Streamlink is exiting with an error if the first argument of the --player-args param is a single hyphen parameter. Defining the same player parameters in the --player param is working fine.
Operating system and version: tested on Linux, MacOS and Windows
Streamlink and Python version: latest
# just some example commands that don't necessarily make sense
# single hyphen params at the beginning of --player-args are not working
$ streamlink -p vlc -a "-v {filename}" twitch.tv/CHANNEL best
usage: streamlink [OPTIONS] <URL> [STREAM]
streamlink: error: argument -a/--player-args: expected one argument
# no hyphen params at the beginning of --player-args are working fine
$ streamlink -p vlc -a "v {filename}" twitch.tv/CHANNEL best
[cli][info] Found matching plugin twitch for URL twitch.tv/CHANNEL
^CInterrupted! Exiting...
# double hyphen params at the beginning of --player-args are working fine
$ streamlink -p vlc -a "--v {filename}" twitch.tv/CHANNEL best
[cli][info] Found matching plugin twitch for URL twitch.tv/CHANNEL
^CInterrupted! Exiting...
# Windows style params at the beginning of --player-args are working fine
$ streamlink -p vlc -a "/v {filename}" twitch.tv/CHANNEL best
[cli][info] Found matching plugin twitch for URL twitch.tv/CHANNEL
^CInterrupted! Exiting...
This is a limitation of argparse. It can be worked around by using a = to set the value.
eg. -a="-v {filename}" or --player-args="-v {filename}".
Here is a small snippet to recreate the issue:
import argparse
args = argparse.ArgumentParser()
args.add_argument("-t", "--test")
print(args.parse_args())
There was a bug report raised around 10 years ago for this issue :)
the last message on the bug report has a workaround https://bugs.python.org/issue9334
not sure if there is any downside of it.
$ streamlink -p vlc -a "-v {filename}" twitch.tv/CHANNEL best -l info
[cli][info] Found matching plugin twitch for URL twitch.tv/CHANNEL
diff between master 3.7 and patch
https://gist.github.com/back-to/d940a2273a7e58152f4fb9fca79cf454/revisions#diff-df389dc0f92c4a0567555d1f96ff2bf9
master 3.7
https://github.com/python/cpython/blob/3.7/Lib/argparse.py#L2065-L2084
@back-to that might work for us.
Most helpful comment
This is a limitation of
argparse. It can be worked around by using a=to set the value.eg.
-a="-v {filename}"or--player-args="-v {filename}".Here is a small snippet to recreate the issue:
There was a bug report raised around 10 years ago for this issue :)