-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[rh:websockets] Migrate websockets to networking framework #7720
Conversation
Make sure to update |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
if not websockets: | ||
raise ExtractorError('websockets library is not available. Please install it.', expected=True) |
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.
We want to error early
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'll add an equivalent error in ydl.urlopen() when the unsupported request errors come back. Cause extractors shouldn't know about the underlying libs, and we may support many websocket libs in the future.
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.
It will then still error only after the initial webpage request. Checking dependency and erroring before any request is better. We do the same for cryptodome deps
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
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'll add this to the "nice to have" list that we can work on later. It's not required for this to be merged imo. It requires a bit of work which is being started in #7595
# Conflicts: # test/test_networking.py # yt_dlp/YoutubeDL.py
# Conflicts: # test/test_networking.py # yt_dlp/networking/__init__.py # yt_dlp/networking/_helper.py # yt_dlp/networking/_urllib.py
Co-authored-by: pukkandan <pukkandan.ytdlp@gmail.com>
# Conflicts: # requirements.txt
* Adds a basic WebSocket framework * Introduces new minimum `websockets` version of 12.0 * Deprecates `WebSocketsWrapper` Fixes yt-dlp#8439 Authored by: coletdjnz
#8361 blocks this. This requires websockets>=12 which is Py3.8+ only.
Moves our Websocket support (in the form of WebSocketsWrapper) into its own RequestHandler. This way extractors do not need to directly interact with the library.
As part of this I have also created a standard websocket framework - where the standard websocket response has send and recv functions.
Improvements
Known issues
websockets
will not be supported as we move to the synchronous client.Out of scope
Template
Before submitting a pull request make sure you have:
In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:
What is the purpose of your pull request?
Copilot Summary
🤖 Generated by Copilot at 04f8749
Summary
🌐🛠️🧪
This pull request adds support for websockets request handler and response in the networking module, and simplifies the websockets handling in some extractors. It adds the files
_websockets.py
andwebsocket.py
that implement the websockets logic, and modifies the filestest_networking.py
,fc2.py
,niconico.py
,_legacy.py
,_utils.py
, andYoutubeDL.py
to use the new websockets classes and methods. It also fixes a bug in the debug output of the downloader.Walkthrough
_utils.py
file to the_websockets.py
file, and import it in the_legacy.py
file for backward compatibility (link, link, link)test_networking.py
file, and test the validation of different URL schemes and options (link, link, link, link, link, link)