diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index d91fc6c7..74905a31 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -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 diff --git a/couchpotato/core/providers/movie/imdbapi/main.py b/couchpotato/core/providers/movie/imdbapi/main.py index 933538c2..e65048bc 100644 --- a/couchpotato/core/providers/movie/imdbapi/main.py +++ b/couchpotato/core/providers/movie/imdbapi/main.py @@ -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) diff --git a/couchpotato/core/providers/nzb/nzbmatrix/main.py b/couchpotato/core/providers/nzb/nzbmatrix/main.py index 8e82133b..e2b426b0 100644 --- a/couchpotato/core/providers/nzb/nzbmatrix/main.py +++ b/couchpotato/core/providers/nzb/nzbmatrix/main.py @@ -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: