1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-25 01:08:50 -05:00

Merge pull request #1339 from abeloin/patch-anidb_exception

AniDB: Fix generating exception on timeout in PP
This commit is contained in:
Alexandre Beloin 2015-02-19 19:53:38 -05:00
commit ada694b016
2 changed files with 48 additions and 29 deletions

View File

@ -1008,16 +1008,20 @@ def set_up_anidb_connection():
if not sickbeard.ADBA_CONNECTION: if not sickbeard.ADBA_CONNECTION:
anidb_logger = lambda x: logger.log("ANIDB: " + str(x), logger.DEBUG) anidb_logger = lambda x: logger.log("ANIDB: " + str(x), logger.DEBUG)
sickbeard.ADBA_CONNECTION = adba.Connection(keepAlive=True, log=anidb_logger)
if not sickbeard.ADBA_CONNECTION.authed():
try: try:
sickbeard.ADBA_CONNECTION.auth(sickbeard.ANIDB_USERNAME, sickbeard.ANIDB_PASSWORD) sickbeard.ADBA_CONNECTION = adba.Connection(keepAlive=True, log=anidb_logger)
except Exception, e: except Exception as e:
logger.log(u"exception msg: " + str(e)) logger.log(u"anidb exception msg: " + str(e))
return False return False
try:
if not sickbeard.ADBA_CONNECTION.authed():
sickbeard.ADBA_CONNECTION.auth(sickbeard.ANIDB_USERNAME, sickbeard.ANIDB_PASSWORD)
else: else:
return True return True
except Exception as e:
logger.log(u"anidb exception msg: " + str(e))
return False
return sickbeard.ADBA_CONNECTION.authed() return sickbeard.ADBA_CONNECTION.authed()

View File

@ -1227,6 +1227,7 @@ class Home(WebRoot):
rls_require_words=None, anime=None, blackWords=None, whiteWords=None, blacklist=None, whitelist=None, rls_require_words=None, anime=None, blackWords=None, whiteWords=None, blacklist=None, whitelist=None,
scene=None, defaultEpStatus=None): scene=None, defaultEpStatus=None):
anidb_failed = False
if show is None: if show is None:
errString = "Invalid show ID: " + str(show) errString = "Invalid show ID: " + str(show)
if directCall: if directCall:
@ -1269,9 +1270,13 @@ class Home(WebRoot):
t.blacklist = bwl.blackDict["release_group"] t.blacklist = bwl.blackDict["release_group"]
t.groups = [] t.groups = []
if helpers.set_up_anidb_connection(): if helpers.set_up_anidb_connection() and not anidb_failed:
try:
anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=showObj.name) anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=showObj.name)
t.groups = anime.get_groups() t.groups = anime.get_groups()
except Exception as e:
anidb_failed = True
ui.notifications.error('Unable to retreive Fansub Groups from AniDB.')
with showObj.lock: with showObj.lock:
t.show = showObj t.show = showObj
@ -1328,7 +1333,8 @@ class Home(WebRoot):
if whitelist: if whitelist:
whitelist = whitelist.split(",") whitelist = whitelist.split(",")
shortWhiteList = [] shortWhiteList = []
if helpers.set_up_anidb_connection(): if helpers.set_up_anidb_connection() and not anidb_failed:
try:
for groupName in whitelist: for groupName in whitelist:
group = sickbeard.ADBA_CONNECTION.group(gname=groupName) group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
for line in group.datalines: for line in group.datalines:
@ -1337,6 +1343,10 @@ class Home(WebRoot):
else: else:
if not groupName in shortWhiteList: if not groupName in shortWhiteList:
shortWhiteList.append(groupName) shortWhiteList.append(groupName)
except Exception as e:
anidb_failed = True
ui.notifications.error('Unable to retreive data from AniDB.')
shortWhiteList = whitelist
else: else:
shortWhiteList = whitelist shortWhiteList = whitelist
bwl.set_white_keywords_for("release_group", shortWhiteList) bwl.set_white_keywords_for("release_group", shortWhiteList)
@ -1346,7 +1356,8 @@ class Home(WebRoot):
if blacklist: if blacklist:
blacklist = blacklist.split(",") blacklist = blacklist.split(",")
shortBlacklist = [] shortBlacklist = []
if helpers.set_up_anidb_connection(): if helpers.set_up_anidb_connection() and not anidb_failed:
try:
for groupName in blacklist: for groupName in blacklist:
group = sickbeard.ADBA_CONNECTION.group(gname=groupName) group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
for line in group.datalines: for line in group.datalines:
@ -1355,6 +1366,10 @@ class Home(WebRoot):
else: else:
if not groupName in shortBlacklist: if not groupName in shortBlacklist:
shortBlacklist.append(groupName) shortBlacklist.append(groupName)
except Exception as e:
anidb_failed = True
ui.notifications.error('Unable to retreive data from AniDB.')
shortBlacklist = blacklist
else: else:
shortBlacklist = blacklist shortBlacklist = blacklist
bwl.set_black_keywords_for("release_group", shortBlacklist) bwl.set_black_keywords_for("release_group", shortBlacklist)