Skip to content

plugin.api: implement WebsocketClient #4153

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

Merged
merged 1 commit into from
Nov 6, 2021

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Nov 6, 2021

  • bump websocket-client requirement to >=1.2.1,<2.0
  • avoid circular import by importing HTTPSession in session directly
  • implement a common WebsocketClient based on the WebSocketApp API of
    websocket-client, so that plugins don't have to re-implement basic
    boilerplate code
  • automatically apply User-Agent header
  • automatically apply proxy settings
  • set websocket log level (globally)
  • add tests

This is a simple wrapper for websocket-client's WebSocketApp 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 the WebSocketApp 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:

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.

- bump websocket-client requirement to >=1.2.1,<2.0
- avoid circular import by importing HTTPSession in session directly
- implement a common WebsocketClient based on the WebSocketApp API of
  websocket-client, so that plugins don't have to re-implement basic
  boilerplate code
- automatically apply User-Agent header
- automatically apply proxy settings
- set websocket log level (globally)
- add tests
@back-to back-to merged commit aa7cf14 into streamlink:master Nov 6, 2021
@bastimeyer bastimeyer deleted the plugin/api/websocket branch November 6, 2021 14:10
Billy2011 added a commit to Billy2011/streamlink-27 that referenced this pull request Nov 9, 2021
- avoid circular import by importing HTTPSession in session directly
- implement a common WebsocketClient based on the WebSocketApp API of
  websocket-client, so that plugins don't have to re-implement basic
  boilerplate code
- automatically apply User-Agent header
- automatically apply proxy settings
- set websocket log level (globally)
- add tests

Update websocket.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants