diff --git a/pyproject.toml b/pyproject.toml index 92d399e319..97ea4375fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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'", diff --git a/test/test_socks.py b/test/test_socks.py index 68af19d0ca..4b3cf38e9a 100644 --- a/test/test_socks.py +++ b/test/test_socks.py @@ -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() diff --git a/yt_dlp/dependencies/__init__.py b/yt_dlp/dependencies/__init__.py index 0d58da2bd5..d33a8fc332 100644 --- a/yt_dlp/dependencies/__init__.py +++ b/yt_dlp/dependencies/__init__.py @@ -52,7 +52,7 @@ try: - import websockets + import websockets.legacy as websockets except ImportError: websockets = None diff --git a/yt_dlp/networking/_websockets.py b/yt_dlp/networking/_websockets.py index ec55567dae..5073003cbc 100644 --- a/yt_dlp/networking/_websockets.py +++ b/yt_dlp/networking/_websockets.py @@ -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