add option to disable pyOpenSSL usage (#508)
(pyOpenSSL is now disabled by default)
This commit is contained in:
@@ -1683,6 +1683,16 @@ Description * ``true``: Update urllib3's default cipher list
|
||||
=========== =====
|
||||
|
||||
|
||||
pyopenssl
|
||||
---------
|
||||
=========== =====
|
||||
Type ``bool``
|
||||
Default ``false``
|
||||
Description Use `pyOpenSSL <https://www.pyopenssl.org/en/stable/>`__-backed
|
||||
SSL-support.
|
||||
=========== =====
|
||||
|
||||
|
||||
|
||||
API Tokens & IDs
|
||||
================
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user