From 3158150cb758f4b0a582a2bccf2bc88385e27a27 Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 4 May 2021 22:36:18 +0530 Subject: [utils] Add `network_exceptions` --- yt_dlp/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'yt_dlp/utils.py') diff --git a/yt_dlp/utils.py b/yt_dlp/utils.py index eb266dda7..08e2d19d2 100644 --- a/yt_dlp/utils.py +++ b/yt_dlp/utils.py @@ -2361,6 +2361,12 @@ class YoutubeDLError(Exception): pass +network_exceptions = [compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error] +if hasattr(ssl, 'CertificateError'): + network_exceptions.append(ssl.CertificateError) +network_exceptions = tuple(network_exceptions) + + class ExtractorError(YoutubeDLError): """Error during info extraction.""" @@ -2369,7 +2375,7 @@ class ExtractorError(YoutubeDLError): If expected is set, this is a normal error message and most likely not a bug in yt-dlp. """ - if sys.exc_info()[0] in (compat_urllib_error.URLError, socket.timeout, UnavailableVideoError): + if sys.exc_info()[0] in network_exceptions: expected = True if video_id is not None: msg = video_id + ': ' + msg -- cgit v1.2.3