session.resolve_url: return plugin class + URL #4163
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Breaking change:
Instead of resolving a plugin instance in
Streamlink.resolve_url(url)
from the provided input URL (which can be redirected), resolve the
plugin class and the resulting URL, and cache the tuple. Also affects
Streamlink.resolve_url_no_redirect(url)
.The main reason for this change is streamlink_cli and how the plugin
options get set. The plugin options need to be set on the class before
it gets initialized, so that the instance can access the options in its
constructor method. This also fixes any kind of state stored on the
plugin instance.
Resolves #4091
Resolves #4161
Notes
Updating the URL in
streamlink_cli
's argument parser setup and removing the redirect logic fromStreamlink.resolve_url()
(as suggested here: #4091 (comment)) didn't seem to be trivial because of how the session is set up and how plugin config files are handled insetup_config_args()
, which gets called twice beforehandle_url()
gets called. The current solution should be good enough, and the logic ofstreamlink.streams()
does not get affected because of that, which is good.streamlink_cli
, but you can check for yourself that it's working by adding a breakpoint in one of the plugin constructors.handle_url()
if the input and resolved URL are different.handle_url()
)