-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
plugins: turn mux-subtitles into a global argument #3324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
might be useful if you also add this plugin option to the log output
streamlink/src/streamlink_cli/main.py Lines 557 to 564 in 49ce436
maybe not important for |
That would require refactoring the Regarding the other arguments which you've mentioned, I'm not sure if making them global is a good idea, because they depend on the input URL what's being done, and this can be confusing or lead to user issues when used incorrectly, especially purge-credentials. Global username/email/password/token/etc arguments could work, but since there's no unique scheme/pattern, that would require having a lot of global arguments and the list of supported plugins would be confusing. The mux-subtitles argument works in a global context because it's an independent thing. |
49ce436
to
3c2554e
Compare
Added the Just noticed some changes I've missed which should have been reverted. Will force-push again in a minute... |
3c2554e
to
dc319e0
Compare
- Add `is_global` parameter to `streamlink.options.Argument` Global plugin arguments reference Streamlink's global arguments by name and cannot receive any other parameters, like `required`, etc. - In `streamlink_cli.main.setup_plugin_args`, find the global argument references of each plugin, set the available default values and add the plugin to the argument's `plugins` list, which will be read by the docs generator - In `streamlink_cli.main.setup_plugin_options`, set the provided global argument values on the plugin's `options` dictionary - Refactor docs/ext_argparse - Don't override argparse.ArgumentParser when importing the parser - Add list of supported plugins to the parameter description if the `plugins` list is set on the argparse action object - Add/improve/fix tests
This removes the old plugin-specific arguments: - `--funimation-mux-subtitles` - `--pluzz-mux-subtitles` - `--rtve-mux-subtitles` - `--svtplay-mux-subtitles` - `--vimeo-mux-subtitles` and replaces it with a single global `--mux-subtitles` argument. Also adds `mux-subtitles` to the Session options.
dc319e0
to
b3e0c67
Compare
Looks good, but I'd like to add somethings to the tests. Lemme see if it's feasible.... |
As an additional note, for this to really make sense I think we need to move the argument definition from the CLI module in to the main |
The test I added shows the strong coupling between the CLI and the main module. |
if hasattr(action, "plugins") and len(action.plugins) > 0: | ||
yield f" **Supported plugins:** {', '.join(action.plugins)}" | ||
yield "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice touch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. @bastimeyer should take a look at the meta-test I added though.
Test looks good... Theoretically this could even be extended a bit by checking that no other argument parameters are set, as the global arguments are not supposed to receive any parameters other than the name, but I don't think it's necessary.
That was already the case previously with the regular plugin arguments, because they are reading their values from Why do we even have a separate |
I mean that the definition of the "global arguments" should be moved to the
|
True, I didn't think about that while writing my previous comment. If you want to move all "global arguments" to That's not an issue of this PR though. Btw, decoupling plugin arguments from their plugin modules is another issue and would probably an annoyance later on if we change/improve the plugin import system. |
That is what I was thinking. Perhaps I will solidify my ideas in to an issue/PR to be worked on/discussed. |
Any further concerns? I think this should be good now. All other things mentioned here are unrelated to the specific changes here. |
- Add `is_global` parameter to `streamlink.options.Argument` Global plugin arguments reference Streamlink's global arguments by name and cannot receive any other parameters, like `required`, etc. - In `streamlink_cli.main.setup_plugin_args`, find the global argument references of each plugin, set the available default values and add the plugin to the argument's `plugins` list, which will be read by the docs generator - In `streamlink_cli.main.setup_plugin_options`, set the provided global argument values on the plugin's `options` dictionary - Refactor docs/ext_argparse - Don't override argparse.ArgumentParser when importing the parser - Add list of supported plugins to the parameter description if the `plugins` list is set on the argparse action object - Add/improve/fix tests streamlink#3324
Closes #3282
Split into two commits. See the commit messages for the descriptions.
Since the argparse docs extension had to be refactored, here's a demonstration of the overall CLI docs changes, to make sure that nothing else changed: