diff options
author | Sergey M․ <dstftw@gmail.com> | 2020-09-18 03:41:16 +0700 |
---|---|---|
committer | Sergey M․ <dstftw@gmail.com> | 2020-09-18 03:41:16 +0700 |
commit | f8c7bed133fe729a9e26f23e5685559e3fa12eb1 (patch) | |
tree | e77e8a9fc7b2525aa66aaef7ce8d5fac28f99bc9 | |
parent | cdc55e666f3f9c795ed74c478c6a249d992cf93f (diff) | |
download | youtube-dl-f8c7bed133fe729a9e26f23e5685559e3fa12eb1.tar.gz youtube-dl-f8c7bed133fe729a9e26f23e5685559e3fa12eb1.tar.bz2 youtube-dl-f8c7bed133fe729a9e26f23e5685559e3fa12eb1.zip |
[extractor/common] Handle ssl.CertificateError in _request_webpage (closes #26601)
ssl.CertificateError is raised on some python versions <= 3.7.x
-rw-r--r-- | youtube_dl/extractor/common.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index a61753b17..f740ddad1 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -10,6 +10,7 @@ import os import random import re import socket +import ssl import sys import time import math @@ -623,9 +624,12 @@ class InfoExtractor(object): url_or_request = update_url_query(url_or_request, query) if data is not None or headers: url_or_request = sanitized_Request(url_or_request, data, headers) + exceptions = [compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error] + if hasattr(ssl, 'CertificateError'): + exceptions.append(ssl.CertificateError) try: return self._downloader.urlopen(url_or_request) - except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: + except tuple(exceptions) as err: if isinstance(err, compat_urllib_error.HTTPError): if self.__can_accept_status_code(err, expected_status): # Retain reference to error to prevent file object from |