Private GIT

Skip to content
Snippets Groups Projects
Commit f9022cbb authored by medariox's avatar medariox
Browse files

Avoid iteration on empty exisiting_subtitles, renamed few variables, might fix issue #340

parent 1512ffe0
Branches
Tags
No related merge requests found
...@@ -195,11 +195,11 @@ def download_subtitles(subtitles_info): # pylint: disable=too-many-locals, too- ...@@ -195,11 +195,11 @@ def download_subtitles(subtitles_info): # pylint: disable=too-many-locals, too-
subtitles_info['episode']), logger.DEBUG) subtitles_info['episode']), logger.DEBUG)
return existing_subtitles, None return existing_subtitles, None
for sub in subtitles_list: for subtitle in subtitles_list:
matches = sub.get_matches(video, hearing_impaired=False) matches = subtitle.get_matches(video, hearing_impaired=False)
score = subliminal.subtitle.compute_score(matches, video) score = subliminal.subtitle.compute_score(matches, video)
logger.log(u"[%s] Subtitle score for %s is: %s (min=%s)" logger.log(u"[%s] Subtitle score for %s is: %s (min=%s)"
% (sub.provider_name, sub.id, score, user_score), logger.DEBUG) % (subtitle.provider_name, subtitle.id, score, user_score), logger.DEBUG)
found_subtitles = pool.download_best_subtitles(subtitles_list, video, languages=languages, found_subtitles = pool.download_best_subtitles(subtitles_list, video, languages=languages,
hearing_impaired=sickbeard.SUBTITLES_HEARING_IMPAIRED, hearing_impaired=sickbeard.SUBTITLES_HEARING_IMPAIRED,
...@@ -238,7 +238,7 @@ def download_subtitles(subtitles_info): # pylint: disable=too-many-locals, too- ...@@ -238,7 +238,7 @@ def download_subtitles(subtitles_info): # pylint: disable=too-many-locals, too-
run_subs_extra_scripts(subtitles_info, subtitle, video, single=not sickbeard.SUBTITLES_MULTI) run_subs_extra_scripts(subtitles_info, subtitle, video, single=not sickbeard.SUBTITLES_MULTI)
new_subtitles = sorted({subtitle.language.opensubtitles for subtitle in found_subtitles}) new_subtitles = sorted({subtitle.language.opensubtitles for subtitle in found_subtitles})
current_subtitles = sorted({subtitle for subtitle in new_subtitles + existing_subtitles}) current_subtitles = sorted({subtitle for subtitle in new_subtitles + existing_subtitles}) if existing_subtitles else new_subtitles
if not sickbeard.SUBTITLES_MULTI and len(found_subtitles) == 1: if not sickbeard.SUBTITLES_MULTI and len(found_subtitles) == 1:
new_code = found_subtitles[0].language.opensubtitles new_code = found_subtitles[0].language.opensubtitles
if new_code not in existing_subtitles: if new_code not in existing_subtitles:
...@@ -371,11 +371,11 @@ class SubtitlesFinder(object): ...@@ -371,11 +371,11 @@ class SubtitlesFinder(object):
min_score=user_score, min_score=user_score,
only_one=not sickbeard.SUBTITLES_MULTI) only_one=not sickbeard.SUBTITLES_MULTI)
for sub in subtitles_list: for subtitle in subtitles_list:
matches = sub.get_matches(video, hearing_impaired=False) matches = subtitle.get_matches(video, hearing_impaired=False)
score = subliminal.subtitle.compute_score(matches, video) score = subliminal.subtitle.compute_score(matches, video)
logger.log(u"[%s] Subtitle score for %s is: %s (min=%s)" logger.log(u"[%s] Subtitle score for %s is: %s (min=%s)"
% (sub.provider_name, sub.id, score, user_score), logger.DEBUG) % (subtitle.provider_name, subtitle.id, score, user_score), logger.DEBUG)
downloaded_languages = set() downloaded_languages = set()
for subtitle in found_subtitles: for subtitle in found_subtitles:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment