From a457d2639598b82ceac2bf7d24467277899637cc Mon Sep 17 00:00:00 2001 From: DiMartinoXBMC Date: Sat, 12 Mar 2016 20:47:49 +0300 Subject: [PATCH] antizapret fix by inpos --- Core.py | 14 +++++++++++++- SearcherABC.py | 38 ++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Core.py b/Core.py index 74ff169..36360cb 100644 --- a/Core.py +++ b/Core.py @@ -276,7 +276,19 @@ class Core: # self.Downloader.__exit__() #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={}): db = DownloadDB() diff --git a/SearcherABC.py b/SearcherABC.py index 18638a4..1e4a432 100644 --- a/SearcherABC.py +++ b/SearcherABC.py @@ -33,7 +33,7 @@ import sys import xbmcgui import xbmc import Localization -from functions import log, debug +from functions import log, debug, showMessage class SearcherABC: @@ -47,13 +47,6 @@ class SearcherABC: 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): ''' Retrieve keyword from the input and return a list of tuples: @@ -110,19 +103,24 @@ class SearcherABC: def makeRequest(self, url, data={}, headers={}): self.load_cookie() + opener = None if self.proxy == 1: - from resources.proxy import antizapret - opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar)) - config = antizapret.config() - self.debug('[antizapret]: '+str(config["domains"])) - self.debug('[antizapret]: '+str(config["server"])) - elif self.proxy == 2: - from resources.proxy import immunicity - 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"])) - else: + try: + from resources.proxy import antizapret + opener = urllib2.build_opener(antizapret.AntizapretProxyHandler(), urllib2.HTTPCookieProcessor(self.cookieJar)) + 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!') + #elif self.proxy == 2: + # from resources.proxy import immunicity + # 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.addheaders = headers if 0 < len(data):