mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 11:31:29 +01:00
Use legacy websockets API
websockets 14 uses the legacy API by default. Explictly use the legacy API so that yt-dlp works with websockets 14+. websockets supports the legacy API until 2030. Ref: https://websockets.readthedocs.io/en/stable/howto/upgrade.html Ref: https://websockets.readthedocs.io/en/stable/project/changelog.html#backwards-incompatible-changes
This commit is contained in:
parent
f919729538
commit
71299aaddb
|
@ -52,7 +52,7 @@ default = [
|
|||
"pycryptodomex",
|
||||
"requests>=2.32.2,<3",
|
||||
"urllib3>=1.26.17,<3",
|
||||
"websockets>=13.0,<14",
|
||||
"websockets>=13.0",
|
||||
]
|
||||
curl-cffi = [
|
||||
"curl-cffi==0.5.10; os_name=='nt' and implementation_name=='cpython'",
|
||||
|
|
|
@ -212,9 +212,9 @@ def do_GET(self):
|
|||
|
||||
class SocksWebSocketTestRequestHandler(SocksTestRequestHandler):
|
||||
def handle(self):
|
||||
import websockets.sync.server
|
||||
import websockets.legacy.sync.server
|
||||
protocol = websockets.ServerProtocol()
|
||||
connection = websockets.sync.server.ServerConnection(socket=self.request, protocol=protocol, close_timeout=0)
|
||||
connection = websockets.legacy.sync.server.ServerConnection(socket=self.request, protocol=protocol, close_timeout=0)
|
||||
connection.handshake()
|
||||
connection.send(json.dumps(self.socks_info))
|
||||
connection.close()
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
|
||||
|
||||
try:
|
||||
import websockets
|
||||
import websockets.legacy as websockets
|
||||
except ImportError:
|
||||
websockets = None
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
if websockets_version < (13, 0):
|
||||
raise ImportError('Only websockets>=13.0 is supported')
|
||||
|
||||
import websockets.sync.client
|
||||
import websockets.legacy.sync.client
|
||||
from websockets.uri import parse_uri
|
||||
|
||||
# In websockets Connection, recv_exc and recv_events_exc are defined
|
||||
|
@ -45,7 +45,7 @@
|
|||
# where the recv events handler thread tries to use these attributes before they are defined [2].
|
||||
# 1: https://github.com/python-websockets/websockets/blame/de768cf65e7e2b1a3b67854fb9e08816a5ff7050/src/websockets/sync/connection.py#L93
|
||||
# 2: "AttributeError: 'ClientConnection' object has no attribute 'recv_events_exc'. Did you mean: 'recv_events'?"
|
||||
import websockets.sync.connection # isort: split
|
||||
import websockets.legacy.sync.connection # isort: split
|
||||
with contextlib.suppress(Exception):
|
||||
websockets.sync.connection.Connection.recv_exc = None
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user