ssl fix
This commit is contained in:
		
							parent
							
								
									6597ba8555
								
							
						
					
					
						commit
						e1360e2b97
					
				@ -26,6 +26,7 @@ import re
 | 
				
			|||||||
from StringIO import StringIO
 | 
					from StringIO import StringIO
 | 
				
			||||||
import gzip
 | 
					import gzip
 | 
				
			||||||
import HTMLParser
 | 
					import HTMLParser
 | 
				
			||||||
 | 
					import ssl
 | 
				
			||||||
from datetime import date
 | 
					from datetime import date
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import Localization
 | 
					import Localization
 | 
				
			||||||
@ -182,6 +183,12 @@ class Content:
 | 
				
			|||||||
    def makeRequest(self, url, data={}, headers=[]):
 | 
					    def makeRequest(self, url, data={}, headers=[]):
 | 
				
			||||||
        self.cookieJar = cookielib.CookieJar()
 | 
					        self.cookieJar = cookielib.CookieJar()
 | 
				
			||||||
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.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
 | 
					        opener.addheaders = headers
 | 
				
			||||||
        if 0 < len(data):
 | 
					        if 0 < len(data):
 | 
				
			||||||
            encodedData = urllib.urlencode(data)
 | 
					            encodedData = urllib.urlencode(data)
 | 
				
			||||||
 | 
				
			|||||||
@ -35,6 +35,7 @@ import xbmc
 | 
				
			|||||||
import Localization
 | 
					import Localization
 | 
				
			||||||
from functions import log, debug, showMessage
 | 
					from functions import log, debug, showMessage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import ssl
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SearcherABC:
 | 
					class SearcherABC:
 | 
				
			||||||
    searchIcon = '/icons/video.png'
 | 
					    searchIcon = '/icons/video.png'
 | 
				
			||||||
@ -103,19 +104,24 @@ class SearcherABC:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    def makeRequest(self, url, data={}, headers={}):
 | 
					    def makeRequest(self, url, data={}, headers={}):
 | 
				
			||||||
        self.load_cookie()
 | 
					        self.load_cookie()
 | 
				
			||||||
        opener = None
 | 
					        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
				
			||||||
        if self.proxy == 1:
 | 
					        if self.proxy == 1:
 | 
				
			||||||
            try:
 | 
					            try:
 | 
				
			||||||
                from resources.proxy import antizapret
 | 
					                from resources.proxy import antizapret
 | 
				
			||||||
                opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
					                opener.add_handler(antizapret.AntizapretProxyHandler())
 | 
				
			||||||
                config = antizapret.config()
 | 
					                config = antizapret.config()
 | 
				
			||||||
                self.debug('[antizapret]: '+str(config["domains"]))
 | 
					                self.debug('[antizapret]: '+str(config["domains"]))
 | 
				
			||||||
                self.debug('[antizapret]: '+str(config["server"]))
 | 
					                self.debug('[antizapret]: '+str(config["server"]))
 | 
				
			||||||
            except:
 | 
					            except:
 | 
				
			||||||
                showMessage('AntiZapret', Localization.localize('Error'))
 | 
					                showMessage('AntiZapret', Localization.localize('Error'))
 | 
				
			||||||
                self.debug('[antizapret]: OFF!')
 | 
					                self.debug('[antizapret]: OFF!')
 | 
				
			||||||
        if not opener:
 | 
					        # python ssl Context support - PEP 0466
 | 
				
			||||||
            opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar))
 | 
					        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
 | 
					        opener.addheaders = headers
 | 
				
			||||||
        if 0 < len(data):
 | 
					        if 0 < len(data):
 | 
				
			||||||
            encodedData = urllib.urlencode(data)
 | 
					            encodedData = urllib.urlencode(data)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user