-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
chore: make mux-subtitles a global CLI argument #3282
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
bastimeyer
left a comment
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.
I had already made roughly the same changes on my local repo and was testing the subtitle muxing before committing and pushing it, but I ran into an issue with the muxing itself, so I took a break. The issue is unrelated to the parameter changes, but the whole muxing seems to be broken when the subtitle stream ends early and the stream gets shut down. See this input for the pluzz plugin for example (requires a French IP address):
https://www.france.tv/documentaires/voyages/1081133-les-voltigeurs-du-lagon.html
Anyway, I had also added this decorator to the base Plugin class and applied it to the _get_streams methods (or the according sub-calls where subtitles are supported, eg. VODs):
@classmethod
def supports_subtitles(cls, func):
def decorator(self, *args, **kwargs):
if not self.session.get_option("mux-subtitles"):
self.logger.info("This plugin supports subtitle muxing via --mux-subtitles")
return func(self, *args, **kwargs)
return decoratorIf you don't like the info log, then we need to annotate the supported plugin classes and add them to the docs (automatically).
| output.add_argument( | ||
| "--mux-subtitles", | ||
| action="store_true", | ||
| help=""" | ||
| Automatically mux available subtitles in to the output stream. | ||
| If supported by the plugin. | ||
| """, | ||
| ) |
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.
The parameter belongs into the transport group, I think.
You'll also have to add it to streamlink_cli.main.setup_options and streamlink.plugin.plugin. In streamlink.plugin.plugin, where the self.session.get_option call reads from, the parameter name needs to include a dash and not an underscore character. This needs to be changed in each plugin.
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.
I figured as it affects the output it could go in there, but maybe transport makes sense.
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.
re:decorator, that looks like a nice idea - but maybe it could be applied to the plugin and that information could be picked up in help somewhere. There is perhaps the possibility for something generic here too.
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.
The more I look at it, I think that there is something we could do similar to how PluginArguments works for plugins, but for Streamlink that way other interfaces could interrogate streamlink to find out which options are supported.
|
I believe once the subtitle muxing parameters have been merged into one global parameter, 2.0.0 should be pretty much ready, at least all the mandatory changes. Everything else is very minor and optional, and this here is probably the last remaining thing which makes sense including in a major version bump. I'm not sure, what exactly you have in mind with a plugin-supported parameter list and how it'll work, but if this is too much effort now, this can be done later on as well, I believe. The only thing that makes these changes critical right now is the removal of the individual CLI parameters. |
|
While subtitles are being addressed here, is it also worth considering better options for subtitle selection? The problem at the moment is that not all sites will list subtitles in the standard locale format, i.e. formatted as There are perhaps 3 possible options to address this:
Thoughts? |
|
@mkbloke Different issue, let's not discuss this here. @beardypig I've been working on adding global argument references to the plugins, like you've suggested, and I'm running into some issues due to how argparse works. My idea was this:
However, the issue I'm facing with this approach is that the docs extension is using a custom argparse "hook", because accessing the available/registered arguments on an argparse parser requires accessing private interfaces: streamlink/docs/ext_argparse.py Lines 37 to 59 in f0b35b6
This means that the docs extension needs to be refactored for the private argparse interfaces. This is fairly straightforward though with one exception, and this is causing some issues which I haven't fully figured out yet and it has something to do with how argparse registers/processes the arguments. |
|
Nvm, found the issue... I will submit a PR later today or tomorrow. |
removes the plugin specific
mux-subtitlesarguments in favour a a global--mux-subtitlesoption.