IMDBapi shorter timeout
This commit is contained in:
@@ -198,7 +198,7 @@ class Plugin(object):
|
|||||||
log.error("Something went wrong when finishing the plugin function. Could not find the 'is_running' key")
|
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):
|
def getCache(self, cache_key, url = None, timeout = 300, url_timeout = 10):
|
||||||
cache = Env.get('cache').get(cache_key)
|
cache = Env.get('cache').get(cache_key)
|
||||||
if cache:
|
if cache:
|
||||||
if not Env.get('dev'): log.debug('Getting cache %s' % cache_key)
|
if not Env.get('dev'): log.debug('Getting cache %s' % cache_key)
|
||||||
@@ -206,7 +206,7 @@ class Plugin(object):
|
|||||||
|
|
||||||
if url:
|
if url:
|
||||||
try:
|
try:
|
||||||
data = self.urlopen(url)
|
data = self.urlopen(url, timeout = url_timeout)
|
||||||
self.setCache(cache_key, data, timeout = timeout)
|
self.setCache(cache_key, data, timeout = timeout)
|
||||||
return data
|
return data
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class IMDBAPI(MovieProvider):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
cache_key = 'imdbapi.cache.%s' % q
|
cache_key = 'imdbapi.cache.%s' % q
|
||||||
cached = self.getCache(cache_key, self.urls['search'] % tryUrlencode({'t': name_year.get('name'), 'y': name_year.get('year', '')}))
|
cached = self.getCache(cache_key, self.urls['search'] % tryUrlencode({'t': name_year.get('name'), 'y': name_year.get('year', '')}), url_timeout = 3)
|
||||||
|
|
||||||
if cached:
|
if cached:
|
||||||
result = self.parseMovie(cached)
|
result = self.parseMovie(cached)
|
||||||
@@ -49,7 +49,7 @@ class IMDBAPI(MovieProvider):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
cache_key = 'imdbapi.cache.%s' % identifier
|
cache_key = 'imdbapi.cache.%s' % identifier
|
||||||
cached = self.getCache(cache_key, self.urls['info'] % identifier)
|
cached = self.getCache(cache_key, self.urls['info'] % identifier, url_timeout = 3)
|
||||||
|
|
||||||
if cached:
|
if cached:
|
||||||
result = self.parseMovie(cached)
|
result = self.parseMovie(cached)
|
||||||
|
|||||||
Reference in New Issue
Block a user