A feature-rich command-line audio/video downloader
[rh:websockets] Add legacy `connect` workaround for >=17.1 (#17747)
bashonlya29f2a2b926c
diff --git a/yt_dlp/networking/_websockets.py b/yt_dlp/networking/_websockets.pyindex fd8730ac7e..7813c5f9ef 100644--- a/yt_dlp/networking/_websockets.py+++ b/yt_dlp/networking/_websockets.py@@ -164,6 +164,11 @@ class WebsocketsRH(WebSocketRequestHandler):user_agent_header=None,ssl=ssl_ctx if wsuri.secure else None,close_timeout=0, # not ideal, but prevents yt-dlp hanging+ # Workaround for websockets>=17.1 support:+ # connect() is intended to be used as a context manager and other usage has been deprecated.+ # The `legacy` flag was added in 17.1 for backwards compat and has not yet been deprecated.+ # Ref: https://github.com/python-websockets/websockets/commit/1f7f0e537233ac82e4ca51921678963c696c8c08+ **({'legacy': True} if websockets_version >= (17, 1) else {}),)return WebsocketsResponseAdapter(conn, url=request.url)