plugin.api: implement WebsocketClient #4153
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.
websocket-client, so that plugins don't have to re-implement basic
boilerplate code
This is a simple wrapper for
websocket-client
'sWebSocketApp
class, which sets the HTTP header of the initialization request and which sets the HTTP proxy options from the session instance. The tests therefore don't test any actual websocket functionality, only the correct usage of theWebSocketApp
API.Another important change is the update of the
websocket-client
version requirement from>=0.58.0
to>=1.2.1,<2.0
. Their 1.0.0 release dropped support for py2, so this won't affect Streamlink, but some parameters were added between 1.0.0 and 1.2.1, so I had to bump the requirement.There are three plugins which are currently implementing websockets:
nicolive
- via the high levelWebSocketApp
APIRetrieves the HLS URL from the websocket connection and needs to send custom pong/keep-alive responses
bastimeyer:plugin/api/websocket...bastimeyer:plugins/nicolive/rewrite
twitcasting
- via high levelWebSocketApp
APIStream data is served via the websocket connection
bastimeyer:plugin/api/websocket...bastimeyer:plugins/twitcasting/websocket
ustreamtv
- via the low levelcreate_connection
APIRetrieves stream segment URLs from the websocket connection
This PR does not update the plugins. I will do this in separate PRs. I've already finished nicolive (complete rewrite) and twitcasting (websocket and custom stream class replacement). ustreamtv requires a complete rewrite as well and I'm still working on it (see #4040). I'm opening this PR now because I'm quite confident that ustreamtv won't require any further changes in the
WebsocketClient
.