mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-01 00:43:37 +00:00
Fixed typo in TVDB Api code
Updated cache handler code
This commit is contained in:
parent
6a1ccef8d9
commit
3db51ef268
3 changed files with 19 additions and 10 deletions
|
@ -200,12 +200,17 @@ class CacheController(object):
|
|||
self.cache.set(cache_url, resp)
|
||||
|
||||
# If we want to cache sites not setup with cache headers then add the proper headers and keep the response
|
||||
if self.cache_all:
|
||||
expires = datetime.datetime.utcnow() + datetime.timedelta(days=(25 * 365))
|
||||
expires = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||
headers = {'Cache-Control': 'public,max-age=%d' % int(3600),
|
||||
'Expires': expires}
|
||||
elif self.cache_all and getattr(resp.headers, 'cache-control', None) is None:
|
||||
headers = {'Cache-Control': 'public,max-age=%d' % int(3600)}
|
||||
resp.headers.update(headers)
|
||||
|
||||
if getattr(resp.headers, 'expires', None) is None:
|
||||
expires = datetime.datetime.utcnow() + datetime.timedelta(days=(25 * 365))
|
||||
expires = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
|
||||
headers = {'Expires': expires}
|
||||
resp.headers.update(headers)
|
||||
|
||||
# Add resp to cache
|
||||
self.cache.set(cache_url, resp)
|
||||
|
||||
# Add to the cache if the response headers demand it. If there
|
||||
|
|
|
@ -428,13 +428,15 @@ class Tvdb:
|
|||
if cache is True:
|
||||
self.config['cache_enabled'] = True
|
||||
self.sess = cachecontrol.CacheControl(requests.Session(),
|
||||
cache=caches.FileCache(self._getTempDir()), cache_all=True)
|
||||
cache_all=True,
|
||||
cache=caches.FileCache(self._getTempDir()))
|
||||
elif cache is False:
|
||||
self.config['cache_enabled'] = False
|
||||
elif isinstance(cache, basestring):
|
||||
self.config['cache_enabled'] = True
|
||||
self.sess = cachecontrol.CacheControl(requests.Session(),
|
||||
cache=caches.FileCache(cache), cache_all=True)
|
||||
cache_all=True,
|
||||
cache=caches.FileCache(cache))
|
||||
else:
|
||||
raise ValueError("Invalid value for Cache %r (type was %s)" % (cache, type(cache)))
|
||||
|
||||
|
@ -537,7 +539,7 @@ class Tvdb:
|
|||
|
||||
# get response from TVDB
|
||||
if self.config['cache_enabled']:
|
||||
resp = self.sess.get(url, params=sorted(params))
|
||||
resp = self.sess.get(url, params=params)
|
||||
else:
|
||||
resp = requests.get(url, params=params)
|
||||
|
||||
|
|
|
@ -271,13 +271,15 @@ class TVRage:
|
|||
if cache is True:
|
||||
self.config['cache_enabled'] = True
|
||||
self.sess = cachecontrol.CacheControl(requests.Session(),
|
||||
cache=caches.FileCache(self._getTempDir()), cache_all=True)
|
||||
cache_all=True,
|
||||
cache=caches.FileCache(self._getTempDir()))
|
||||
elif cache is False:
|
||||
self.config['cache_enabled'] = False
|
||||
elif isinstance(cache, basestring):
|
||||
self.config['cache_enabled'] = True
|
||||
self.sess = cachecontrol.CacheControl(requests.Session(),
|
||||
cache=caches.FileCache(cache), cache_all=True)
|
||||
cache_all=True,
|
||||
cache=caches.FileCache(cache))
|
||||
else:
|
||||
raise ValueError("Invalid value for Cache %r (type was %s)" % (cache, type(cache)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue