Skip to content

A feature-rich command-line audio/video downloader

[socks] Report errors elegantly when credentails are required but missing

Yen Chi Hsuan54f54fcca7af
diff --git a/ChangeLog b/ChangeLog
index d699acb315..8dc6e68575 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
version <unreleased>
+Core
+
+* [socks] Handle cases where credentials are required but missing
+
Extractors
- [azubu] Remove extractor (#12813)
* [porn91] Fix extraction (#12814)
diff --git a/youtube_dl/socks.py b/youtube_dl/socks.py
index 0f5d7bdb21..5d4adbe72d 100644
--- a/youtube_dl/socks.py
+++ b/youtube_dl/socks.py
@@ -193,9 +193,10 @@ class sockssocket(socket.socket):
self._check_response_version(SOCKS5_VERSION, version)
- if method == Socks5Auth.AUTH_NO_ACCEPTABLE:
+ if method == Socks5Auth.AUTH_NO_ACCEPTABLE or (
+ method == Socks5Auth.AUTH_USER_PASS and (not self._proxy.username or not self._proxy.password)):
self.close()
- raise Socks5Error(method)
+ raise Socks5Error(Socks5Auth.AUTH_NO_ACCEPTABLE)
if method == Socks5Auth.AUTH_USER_PASS:
username = self._proxy.username.encode('utf-8')