Urlopen try,except fixes
This commit is contained in:
@@ -160,12 +160,20 @@ 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):
|
||||
def getCache(self, cache_key, url = None):
|
||||
cache = Env.get('cache').get(cache_key)
|
||||
if cache:
|
||||
log.debug('Getting cache %s' % cache_key)
|
||||
return cache
|
||||
|
||||
if url:
|
||||
try:
|
||||
data = self.urlopen(url)
|
||||
self.setCache(cache_key, data)
|
||||
return data
|
||||
except:
|
||||
pass
|
||||
|
||||
def setCache(self, cache_key, value, timeout = 300):
|
||||
log.debug('Setting cache %s' % cache_key)
|
||||
Env.get('cache').set(cache_key, value, timeout)
|
||||
|
||||
@@ -34,9 +34,9 @@ class FileManager(Plugin):
|
||||
|
||||
def download(self, url = '', dest = None, overwrite = False):
|
||||
|
||||
file = self.urlopen(url)
|
||||
if not file:
|
||||
log.error('File is empty, don\'t download')
|
||||
try:
|
||||
file = self.urlopen(url)
|
||||
except:
|
||||
return False
|
||||
|
||||
if not dest: # to Cache
|
||||
|
||||
@@ -261,7 +261,10 @@ class Searcher(Plugin):
|
||||
|
||||
nfo = self.getCache(cache_key)
|
||||
if not nfo:
|
||||
nfo = self.urlopen('http://www.srrdb.com/showfile.php?release=%s' % check_name)
|
||||
self.setCache(cache_key, nfo)
|
||||
try:
|
||||
nfo = self.urlopen('http://www.srrdb.com/showfile.php?release=%s' % check_name)
|
||||
self.setCache(cache_key, nfo)
|
||||
except:
|
||||
pass
|
||||
|
||||
return getImdb(nfo) == imdb_id
|
||||
|
||||
Reference in New Issue
Block a user