plugins.kick: solve JS challenge #6325
Closed
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.
The plugin is currently completely broken on master, because Kick has added a JS challenge for being able to access their REST APIs. The required token was previously simply set as a cookie from an initial HTTP request+response made on their front page which we could simply read. Now, a JS challenge similar to Twitch's has to be solved, where the cookie with the token is then set via JS APIs.
So in order to fix the plugin, Streamlink's webbrowser API has to be used where the JS challenge can be solved and the cookie value with the token be read. This works fine, even in headless mode.
I've added token caching, because apparently it's valid for 30 days (according to the cookie expiration times), but the cache expiration time is set to only a day for now, since there's no plugin argument for clearing the cache, and should it become invalid, users would need to remove the cached value manually.
It's probably better though to test the cached token on an API endpoint first and invalidate it if it's not working, and then request a new one. I'll have a look at this later before merging. Just wanted to open this PR now with the current changes.