Play nice with NZBMatrix

This commit is contained in:
Ruud
2012-05-02 23:23:55 +02:00
parent 5d3c99a140
commit 7d4c2e7d04
3 changed files with 11 additions and 5 deletions
+9 -3
View File
@@ -198,7 +198,7 @@ class Plugin(object):
log.error("Something went wrong when finishing the plugin function. Could not find the 'is_running' key")
def getCache(self, cache_key, url = None, timeout = 300, url_timeout = 10):
def getCache(self, cache_key, url = None, *args, **kwargs):
cache = Env.get('cache').get(cache_key)
if cache:
if not Env.get('dev'): log.debug('Getting cache %s' % cache_key)
@@ -206,8 +206,14 @@ class Plugin(object):
if url:
try:
data = self.urlopen(url, timeout = url_timeout)
self.setCache(cache_key, data, timeout = timeout)
cache_timeout = 300
if kwargs.get('cache_timeout'):
cache_timeout = kwargs.get('cache_timeout')
del kwargs['cache_timeout']
data = self.urlopen(url, *args, **kwargs)
self.setCache(cache_key, data, timeout = cache_timeout)
return data
except:
pass
@@ -49,7 +49,7 @@ class IMDBAPI(MovieProvider):
return {}
cache_key = 'imdbapi.cache.%s' % identifier
cached = self.getCache(cache_key, self.urls['info'] % identifier, url_timeout = 3)
cached = self.getCache(cache_key, self.urls['info'] % identifier, timeout = 3)
if cached:
result = self.parseMovie(cached)
@@ -51,7 +51,7 @@ class NZBMatrix(NZBProvider, RSS):
cache_key = 'nzbmatrix.%s.%s' % (movie['library'].get('identifier'), cat_ids)
single_cat = True
data = self.getCache(cache_key, url)
data = self.getCache(cache_key, url, cache_timeout = 1800, headers = {'User-Agent': 'CouchPotato'})
if data:
try:
try: