mirror of
https://github.com/moparisthebest/SickRage
synced 2024-12-23 16:28:49 -05:00
Merge pull request #1339 from abeloin/patch-anidb_exception
AniDB: Fix generating exception on timeout in PP
This commit is contained in:
commit
ada694b016
@ -1008,16 +1008,20 @@ def set_up_anidb_connection():
|
||||
|
||||
if not sickbeard.ADBA_CONNECTION:
|
||||
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:
|
||||
sickbeard.ADBA_CONNECTION.auth(sickbeard.ANIDB_USERNAME, sickbeard.ANIDB_PASSWORD)
|
||||
except Exception, e:
|
||||
logger.log(u"exception msg: " + str(e))
|
||||
sickbeard.ADBA_CONNECTION = adba.Connection(keepAlive=True, log=anidb_logger)
|
||||
except Exception as e:
|
||||
logger.log(u"anidb exception msg: " + str(e))
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
try:
|
||||
if not sickbeard.ADBA_CONNECTION.authed():
|
||||
sickbeard.ADBA_CONNECTION.auth(sickbeard.ANIDB_USERNAME, sickbeard.ANIDB_PASSWORD)
|
||||
else:
|
||||
return True
|
||||
except Exception as e:
|
||||
logger.log(u"anidb exception msg: " + str(e))
|
||||
return False
|
||||
|
||||
return sickbeard.ADBA_CONNECTION.authed()
|
||||
|
||||
|
@ -1227,6 +1227,7 @@ class Home(WebRoot):
|
||||
rls_require_words=None, anime=None, blackWords=None, whiteWords=None, blacklist=None, whitelist=None,
|
||||
scene=None, defaultEpStatus=None):
|
||||
|
||||
anidb_failed = False
|
||||
if show is None:
|
||||
errString = "Invalid show ID: " + str(show)
|
||||
if directCall:
|
||||
@ -1269,9 +1270,13 @@ class Home(WebRoot):
|
||||
t.blacklist = bwl.blackDict["release_group"]
|
||||
|
||||
t.groups = []
|
||||
if helpers.set_up_anidb_connection():
|
||||
anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=showObj.name)
|
||||
t.groups = anime.get_groups()
|
||||
if helpers.set_up_anidb_connection() and not anidb_failed:
|
||||
try:
|
||||
anime = adba.Anime(sickbeard.ADBA_CONNECTION, name=showObj.name)
|
||||
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:
|
||||
t.show = showObj
|
||||
@ -1328,15 +1333,20 @@ class Home(WebRoot):
|
||||
if whitelist:
|
||||
whitelist = whitelist.split(",")
|
||||
shortWhiteList = []
|
||||
if helpers.set_up_anidb_connection():
|
||||
for groupName in whitelist:
|
||||
group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
|
||||
for line in group.datalines:
|
||||
if line["shortname"]:
|
||||
shortWhiteList.append(line["shortname"])
|
||||
else:
|
||||
if not groupName in shortWhiteList:
|
||||
shortWhiteList.append(groupName)
|
||||
if helpers.set_up_anidb_connection() and not anidb_failed:
|
||||
try:
|
||||
for groupName in whitelist:
|
||||
group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
|
||||
for line in group.datalines:
|
||||
if line["shortname"]:
|
||||
shortWhiteList.append(line["shortname"])
|
||||
else:
|
||||
if not groupName in shortWhiteList:
|
||||
shortWhiteList.append(groupName)
|
||||
except Exception as e:
|
||||
anidb_failed = True
|
||||
ui.notifications.error('Unable to retreive data from AniDB.')
|
||||
shortWhiteList = whitelist
|
||||
else:
|
||||
shortWhiteList = whitelist
|
||||
bwl.set_white_keywords_for("release_group", shortWhiteList)
|
||||
@ -1346,15 +1356,20 @@ class Home(WebRoot):
|
||||
if blacklist:
|
||||
blacklist = blacklist.split(",")
|
||||
shortBlacklist = []
|
||||
if helpers.set_up_anidb_connection():
|
||||
for groupName in blacklist:
|
||||
group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
|
||||
for line in group.datalines:
|
||||
if line["shortname"]:
|
||||
shortBlacklist.append(line["shortname"])
|
||||
else:
|
||||
if not groupName in shortBlacklist:
|
||||
shortBlacklist.append(groupName)
|
||||
if helpers.set_up_anidb_connection() and not anidb_failed:
|
||||
try:
|
||||
for groupName in blacklist:
|
||||
group = sickbeard.ADBA_CONNECTION.group(gname=groupName)
|
||||
for line in group.datalines:
|
||||
if line["shortname"]:
|
||||
shortBlacklist.append(line["shortname"])
|
||||
else:
|
||||
if not groupName in shortBlacklist:
|
||||
shortBlacklist.append(groupName)
|
||||
except Exception as e:
|
||||
anidb_failed = True
|
||||
ui.notifications.error('Unable to retreive data from AniDB.')
|
||||
shortBlacklist = blacklist
|
||||
else:
|
||||
shortBlacklist = blacklist
|
||||
bwl.set_black_keywords_for("release_group", shortBlacklist)
|
||||
|
Loading…
Reference in New Issue
Block a user