1
0
mirror of https://github.com/yt-dlp/yt-dlp synced 2025-07-09 15:23:59 -05:00

[utils] Add network_exceptions

This commit is contained in:
pukkandan
2021-05-04 22:36:18 +05:30
parent 6ef6bcbd6b
commit 3158150cb7
4 changed files with 15 additions and 16 deletions

View File

@ -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