Private GIT

Skip to content
Snippets Groups Projects
Commit bb244c55 authored by Fernando's avatar Fernando Committed by fernandog
Browse files

Partialy fix SickRage/sickrage-issues/issues/196

Avoid thread crash if anything goes wrong with sql results
@miigotu @medariox ok?
parent 28a301dc
No related branches found
No related tags found
No related merge requests found
......@@ -439,6 +439,7 @@ class SubtitlesFinder(object):
rules = self._get_rules()
now = datetime.datetime.now()
for ep_to_sub in sql_results:
if not ek(os.path.isfile, ep_to_sub['location']):
......@@ -451,9 +452,7 @@ class SubtitlesFinder(object):
% (ep_to_sub['show_name'], ep_to_sub['season'], ep_to_sub['episode']), logger.DEBUG)
continue
# http://bugs.python.org/issue7980#msg221094
# I dont think this needs done here, but keeping to be safe (Recent shows rule)
datetime.datetime.strptime('20110101', '%Y%m%d')
try:
if ((ep_to_sub['airdate_daydiff'] > 7 and ep_to_sub['searchcount'] < 2 and
now - datetime.datetime.strptime(ep_to_sub['lastsearch'], dateTimeFormat) >
datetime.timedelta(hours=rules['old'][ep_to_sub['searchcount']])) or
......@@ -479,9 +478,9 @@ class SubtitlesFinder(object):
try:
episode_object.download_subtitles()
except Exception as e:
except Exception as error:
logger.log(u'Unable to find subtitles for %s S%02dE%02d. Error: %r'
% (ep_to_sub['show_name'], ep_to_sub['season'], ep_to_sub['episode'], ex(e)), logger.ERROR)
% (ep_to_sub['show_name'], ep_to_sub['season'], ep_to_sub['episode'], ex(error)), logger.ERROR)
continue
new_subtitles = frozenset(episode_object.subtitles).difference(existing_subtitles)
......@@ -489,6 +488,10 @@ class SubtitlesFinder(object):
logger.log(u'Downloaded %s subtitles for %s S%02dE%02d'
% (', '.join(new_subtitles), ep_to_sub['show_name'],
ep_to_sub["season"], ep_to_sub["episode"]))
except Exception as error:
logger.log(u'Error while searching subtitles for %s S%02dE%02d. Error: %r'
% (ep_to_sub['show_name'], ep_to_sub['season'], ep_to_sub['episode'], ex(error)), logger.ERROR)
continue
self.amActive = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment