diff --git a/docs/configuration.rst b/docs/configuration.rst index 23a0d09f..b4d7e605 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1683,6 +1683,16 @@ Description * ``true``: Update urllib3's default cipher list =========== ===== +pyopenssl +--------- +=========== ===== +Type ``bool`` +Default ``false`` +Description Use `pyOpenSSL `__-backed + SSL-support. +=========== ===== + + API Tokens & IDs ================ diff --git a/gallery_dl/extractor/common.py b/gallery_dl/extractor/common.py index 025e1cbf..a36a1d81 100644 --- a/gallery_dl/extractor/common.py +++ b/gallery_dl/extractor/common.py @@ -108,13 +108,7 @@ class Extractor(): cloudflare.cookies.update(self.category, (domain, cookies)) return response if cloudflare.is_captcha(response): - try: - import OpenSSL # noqa - except ImportError: - msg = " - Install 'pyOpenSSL' and try again" - else: - msg = "" - self.log.warning("Cloudflare CAPTCHA" + msg) + self.log.warning("Cloudflare CAPTCHA") msg = "'{} {}' for '{}'".format(code, response.reason, url) if code < 500 and code != 429 and code != 430: @@ -475,10 +469,21 @@ def generate_extractors(extractor_data, symtable, classes): http.cookiejar.MozillaCookieJar.magic_re = re.compile( "#( Netscape)? HTTP Cookie File", re.IGNORECASE) -# Replace default cipher list of urllib3 to avoid Cloudflare CAPTCHAs + +# Undo automatic pyOpenSSL injection by requests +pyopenssl = config.get((), "pyopenssl", False) +if not pyopenssl: + try: + from requests.packages.urllib3.contrib import pyopenssl # noqa + pyopenssl.extract_from_urllib3() + except ImportError: + pass +del pyopenssl + + +# Replace urllib3's default cipher list to avoid Cloudflare CAPTCHAs ciphers = config.get((), "ciphers", True) if ciphers: - logging.getLogger("gallery-dl").debug("Updating urllib3 ciphers") if ciphers is True: ciphers = ( @@ -508,3 +513,4 @@ if ciphers: from requests.packages.urllib3.util import ssl_ # noqa ssl_.DEFAULT_CIPHERS = ciphers del ssl_ +del ciphers diff --git a/test/test_results.py b/test/test_results.py index eef5559d..958e530d 100644 --- a/test/test_results.py +++ b/test/test_results.py @@ -21,7 +21,7 @@ TRAVIS_SKIP = { "exhentai", "kissmanga", "mangafox", "dynastyscans", "nijie", "bobx", "archivedmoe", "archiveofsins", "thebarchive", "fireden", "4plebs", "sankaku", "idolcomplex", "mangahere", "readcomiconline", "mangadex", - "sankakucomplex", "warosu", "fuskator", + "sankakucomplex", "warosu", "fuskator", "patreon", } # temporary issues, etc.