From e1360e2b97ae66073667363a0e7ca74180dd90fb Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Tue, 27 Dec 2016 18:47:09 +0300 Subject: [PATCH] ssl fix --- Content.py | 7 +++++++ SearcherABC.py | 14 ++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Content.py b/Content.py index 0e57fc5..3ce544f 100644 --- a/Content.py +++ b/Content.py @@ -26,6 +26,7 @@ import re from StringIO import StringIO import gzip import HTMLParser +import ssl from datetime import date import Localization @@ -182,6 +183,12 @@ class Content: def makeRequest(self, url, data={}, headers=[]): self.cookieJar = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar)) + # python ssl Context support - PEP 0466 + if hasattr(ssl, '_create_unverified_context'): + ssl_context = ssl._create_unverified_context() + opener.add_handler(urllib2.HTTPSHandler(context=ssl_context)) + else: + opener.add_handler(urllib2.HTTPSHandler()) opener.addheaders = headers if 0 < len(data): encodedData = urllib.urlencode(data) diff --git a/SearcherABC.py b/SearcherABC.py index 913c8d2..6d4b16f 100644 --- a/SearcherABC.py +++ b/SearcherABC.py @@ -35,6 +35,7 @@ import xbmc import Localization from functions import log, debug, showMessage +import ssl class SearcherABC: searchIcon = '/icons/video.png' @@ -103,19 +104,24 @@ class SearcherABC: def makeRequest(self, url, data={}, headers={}): self.load_cookie() - opener = None + opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar)) if self.proxy == 1: try: from resources.proxy import antizapret - opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar)) + opener.add_handler(antizapret.AntizapretProxyHandler()) config = antizapret.config() self.debug('[antizapret]: '+str(config["domains"])) self.debug('[antizapret]: '+str(config["server"])) except: showMessage('AntiZapret', Localization.localize('Error')) self.debug('[antizapret]: OFF!') - if not opener: - opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar)) + # python ssl Context support - PEP 0466 + if hasattr(ssl, '_create_unverified_context'): + ssl_context = ssl._create_unverified_context() + opener.add_handler(urllib2.HTTPSHandler(context=ssl_context)) + else: + opener.add_handler(urllib2.HTTPSHandler()) + opener.addheaders = headers if 0 < len(data): encodedData = urllib.urlencode(data)