From dc0a8deb4088dc92cb7045b00a5a729ddd8f797d Mon Sep 17 00:00:00 2001 From: panni Date: Wed, 8 May 2019 04:14:04 +0200 Subject: [PATCH] core: cf: testing providers: subscene: testing --- Contents/Libraries/Shared/cloudscraper/__init__.py | 13 +++++++++---- Contents/Libraries/Shared/subscene_api/subscene.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Contents/Libraries/Shared/cloudscraper/__init__.py b/Contents/Libraries/Shared/cloudscraper/__init__.py index b34065ec..66d47392 100644 --- a/Contents/Libraries/Shared/cloudscraper/__init__.py +++ b/Contents/Libraries/Shared/cloudscraper/__init__.py @@ -49,17 +49,22 @@ class CipherSuiteAdapter(HTTPAdapter): ########################################################################################################################################################## def init_poolmanager(self, *args, **kwargs): - kwargs['ssl_context'] = create_urllib3_context(ciphers=self.cipherSuite) + if hasattr(ssl, 'PROTOCOL_TLS'): + kwargs['ssl_context'] = create_urllib3_context(ssl_version=getattr(ssl, 'PROTOCOL_TLSv1_3', ssl.PROTOCOL_TLSv1_2), ciphers=self.cipherSuite) + else: + kwargs['ssl_context'] = create_urllib3_context(ssl_version=ssl.PROTOCOL_TLSv1) return super(CipherSuiteAdapter, self).init_poolmanager(*args, **kwargs) ########################################################################################################################################################## def proxy_manager_for(self, *args, **kwargs): - kwargs['ssl_context'] = create_urllib3_context(ciphers=self.cipherSuite) + if hasattr(ssl, 'PROTOCOL_TLS'): + kwargs['ssl_context'] = create_urllib3_context( + ssl_version=getattr(ssl, 'PROTOCOL_TLSv1_3', ssl.PROTOCOL_TLSv1_2), ciphers=self.cipherSuite) + else: + kwargs['ssl_context'] = create_urllib3_context(ssl_version=ssl.PROTOCOL_TLSv1) return super(CipherSuiteAdapter, self).proxy_manager_for(*args, **kwargs) -########################################################################################################################################################## - class CloudScraper(Session): def __init__(self, *args, **kwargs): diff --git a/Contents/Libraries/Shared/subscene_api/subscene.py b/Contents/Libraries/Shared/subscene_api/subscene.py index e2b14ea2..5b53a8c9 100644 --- a/Contents/Libraries/Shared/subscene_api/subscene.py +++ b/Contents/Libraries/Shared/subscene_api/subscene.py @@ -244,7 +244,7 @@ def get_first_film(soup, section, year=None, session=None): def search(term, release=True, session=None, year=None, limit_to=SearchTypes.Exact): - soup = soup_for("%s/subtitles/%s?q=%s" % (SITE_DOMAIN, "release" if release else "title", term), session=session) + soup = soup_for("%s/subtitles/%s?q=%s" % (SITE_DOMAIN, "release" if release else "search", term), session=session) if "Subtitle search by" in str(soup): rows = soup.find("table").tbody.find_all("tr")