antizapret fix by inpos

pull/2/head
DiMartinoXBMC 2016-03-12 20:47:49 +03:00
parent 55cb8797e2
commit a457d26395
2 changed files with 31 additions and 21 deletions

14
Core.py
View File

@ -276,7 +276,19 @@ class Core:
# self.Downloader.__exit__() # self.Downloader.__exit__()
#self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params) #self.Player = AnteoPlayer(userStorageDirectory=self.userStorageDirectory, torrentUrl=torrentUrl, params=params)
xbmcgui.Dialog().ok('Dam Son!','Now send this shit to DiMartino') #xbmcgui.Dialog().ok('Dam Son!','Now send this shit to DiMartino')
from resources.proxy import antizapret
filename = os.path.join(tempdir(),"antizapret.pac_config")
import shelve
from contextlib import contextmanager, closing
with closing(shelve.open(filename, writeback=True)) as d:
import time
log(str(d))
log(str(time.time()))
log(str((time.time() - d["created_at"])))
ttl = 24*3600
if ttl > 0 and (time.time() - d["created_at"]) > ttl:
log('xxx')
def DownloadStatus(self, params={}): def DownloadStatus(self, params={}):
db = DownloadDB() db = DownloadDB()

View File

@ -33,7 +33,7 @@ import sys
import xbmcgui import xbmcgui
import xbmc import xbmc
import Localization import Localization
from functions import log, debug from functions import log, debug, showMessage
class SearcherABC: class SearcherABC:
@ -47,13 +47,6 @@ class SearcherABC:
socket.setdefaulttimeout(10+(10*int(timeout_multi))) socket.setdefaulttimeout(10+(10*int(timeout_multi)))
#def __del__(self):
# print '!!!!!!!!!!!!!!!!!! DIED !!! '+self.__class__.__name__
#def __init__(self):
# print '!!!!!!!!!!!!!!!!!! BORN '+self.__class__.__name__
def search(self, keyword): def search(self, keyword):
''' '''
Retrieve keyword from the input and return a list of tuples: Retrieve keyword from the input and return a list of tuples:
@ -110,19 +103,24 @@ class SearcherABC:
def makeRequest(self, url, data={}, headers={}): def makeRequest(self, url, data={}, headers={}):
self.load_cookie() self.load_cookie()
opener = None
if self.proxy == 1: if self.proxy == 1:
from resources.proxy import antizapret try:
opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar)) from resources.proxy import antizapret
config = antizapret.config() opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar))
self.debug('[antizapret]: '+str(config["domains"])) config = antizapret.config()
self.debug('[antizapret]: '+str(config["server"])) self.debug('[antizapret]: '+str(config["domains"]))
elif self.proxy == 2: self.debug('[antizapret]: '+str(config["server"]))
from resources.proxy import immunicity except:
opener = urllib2.build_opener(immunicity.ImmunicityProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar)) showMessage('AntiZapret', Localization.localize('Error'))
config = immunicity.config() self.debug('[antizapret]: OFF!')
self.debug('[immunicity]: '+str(config["domains"])) #elif self.proxy == 2:
self.debug('[immunicity]: '+str(config["server"])) # from resources.proxy import immunicity
else: # opener = urllib2.build_opener(immunicity.ImmunicityProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar))
# config = immunicity.config()
# self.debug('[immunicity]: '+str(config["domains"]))
# self.debug('[immunicity]: '+str(config["server"]))
if not opener:
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar)) opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookieJar))
opener.addheaders = headers opener.addheaders = headers
if 0 < len(data): if 0 < len(data):