def request(url, method='get', data='', ttl=3600): #returns a cached version if we have a fresh one if ttl == 0: return utils.GET(url) #todo post hash = utils.hash(url) print 'hash for ' + url + ' is ' + hash file = utils.f_translate_path(utils.f_basepath() + '/webcache/' + hash) path = utils.f_translate_path(utils.f_basepath() + '/webcache/') epoch = utils.epoch() if not utils.f_check_existance(path): utils.f_mkdir(path) if utils.f_check_existance(file): f = utils.f_open(file) abs_ttl = int(f[:10]) print abs_ttl print epoch f = f[11:] if not utils.f_check_existance( file) or abs_ttl < epoch: #checks if the milk is sour f = utils.GET(url) #todo post utils.f_write(file, str(epoch + ttl) + f) print 'request new file' else: print 'use cached copy' return f
def request(url,method='get',data='',ttl=3600):#returns a cached version if we have a fresh one if ttl == 0: return utils.GET(url)#todo post hash = utils.hash(url) print 'hash for '+url+' is '+ hash file = utils.f_translate_path(utils.f_basepath() + '/webcache/' + hash) path = utils.f_translate_path(utils.f_basepath() + '/webcache/') epoch = utils.epoch() if not utils.f_check_existance(path): utils.f_mkdir(path) if utils.f_check_existance(file): f = utils.f_open(file) abs_ttl = int(f[:10]) print abs_ttl print epoch f = f[11:] if not utils.f_check_existance(file) or abs_ttl < epoch:#checks if the milk is sour f = utils.GET(url)#todo post utils.f_write(file,str(epoch+ttl)+f) print 'request new file' else: print 'use cached copy' return f
#from time import * #from datetime import date, timedelta from operator import itemgetter #import time import resources.lib.utils as utils import libArd import libArte import libZdf __settings__ = xbmcaddon.Addon() __language__ = __settings__.getLocalizedString addon = xbmcaddon.Addon() translation = addon.getLocalizedString dir = xbmc.validatePath(xbmc.translatePath(__settings__.getAddonInfo('profile'))) if not utils.f_check_existance(dir): utils.f_mkdir(dir) ardLimit = int(addon.getSetting("ardLimit")) zdfLimit = int(addon.getSetting("zdfLimit")) showSubtitles = addon.getSetting("showSubtitles") == "true" hideAudioDisa = addon.getSetting("hideAudioDisa") == "true" helix = False html_parser = HTMLParser.HTMLParser() month = strftime("%m", gmtime()) year = strftime("%Y", gmtime()) startTime = int(round(time.time() * 1000)) viewMode = '515' viewModeA = '515' viewModeB = '515'
def clear_cache(): utils.f_rmdir(utils.f_translate_path(utils.f_basepath() + '/webcache/')) utils.f_mkdir(utils.f_translate_path(utils.f_basepath() + '/webcache/')) return True