From 07c37b82542a96c5e7917f361751d6d297e817f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 23 Apr 2019 20:05:06 -0400 Subject: [PATCH] Fix for subtitles upgrading when a series doesn't have a desired language anymore. --- bazarr/get_subtitle.py | 62 +++++++++++++++++++++-------------------- views/historymovies.tpl | 2 ++ views/historyseries.tpl | 2 ++ 3 files changed, 36 insertions(+), 30 deletions(-) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 520feb175..06eea4886 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -815,36 +815,38 @@ def upgrade_subtitles(): if settings.general.getboolean('use_sonarr'): for i, episode in enumerate(episodes_to_upgrade, 1): - if episode[1] in ast.literal_eval(str(episode[9])): - notifications.write(msg='Upgrading series subtitles...', - queue='upgrade_subtitle', item=i, length=count_episode_to_upgrade) - result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(episode[1])), - episode[3], providers_list, providers_auth, str(episode[4]), - episode[5], 'series', forced_minimum_score=int(episode[2]), is_upgrade=True) - if result is not None: - message = result[0] - path = result[1] - language_code = result[2] - provider = result[3] - score = result[4] - store_subtitles(path_replace(episode[0])) - history_log(3, episode[6], episode[7], message, path, language_code, provider, score) - send_notifications(episode[6], episode[7], message) + if episode[9] != "None": + if episode[1] in ast.literal_eval(str(episode[9])): + notifications.write(msg='Upgrading series subtitles...', + queue='upgrade_subtitle', item=i, length=count_episode_to_upgrade) + result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(episode[1])), + episode[3], providers_list, providers_auth, str(episode[4]), + episode[5], 'series', forced_minimum_score=int(episode[2]), is_upgrade=True) + if result is not None: + message = result[0] + path = result[1] + language_code = result[2] + provider = result[3] + score = result[4] + store_subtitles(path_replace(episode[0])) + history_log(3, episode[6], episode[7], message, path, language_code, provider, score) + send_notifications(episode[6], episode[7], message) if settings.general.getboolean('use_radarr'): for i, movie in enumerate(movies_to_upgrade, 1): - if movie[1] in ast.literal_eval(str(movie[8])): - notifications.write(msg='Upgrading movie subtitles...', - queue='upgrade_subtitle', item=i, length=count_movie_to_upgrade) - result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])), - movie[3], providers_list, providers_auth, str(movie[4]), - movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True) - if result is not None: - message = result[0] - path = result[1] - language_code = result[2] - provider = result[3] - score = result[4] - store_subtitles_movie(path_replace_movie(movie[0])) - history_log_movie(3, movie[6], message, path, language_code, provider, score) - send_notifications_movie(movie[6], message) + if movie[8] != "None": + if movie[1] in ast.literal_eval(str(movie[8])): + notifications.write(msg='Upgrading movie subtitles...', + queue='upgrade_subtitle', item=i, length=count_movie_to_upgrade) + result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])), + movie[3], providers_list, providers_auth, str(movie[4]), + movie[5], 'movie', forced_minimum_score=int(movie[2]), is_upgrade=True) + if result is not None: + message = result[0] + path = result[1] + language_code = result[2] + provider = result[3] + score = result[4] + store_subtitles_movie(path_replace_movie(movie[0])) + history_log_movie(3, movie[6], message, path, language_code, provider, score) + send_notifications_movie(movie[6], message) diff --git a/views/historymovies.tpl b/views/historymovies.tpl index e828f8590..5f4e0d041 100644 --- a/views/historymovies.tpl +++ b/views/historymovies.tpl @@ -87,6 +87,7 @@ % upgradable_criteria = (row[5], row[2], row[8]) % if upgradable_criteria in upgradable_movies: + % if row[6] != "None": % if row[6] and row[7] and row[7] in ast.literal_eval(str(row[6])):
{{row[3]}} @@ -94,6 +95,7 @@ % else: {{row[3]}} % end + % end % else: {{row[3]}} %end diff --git a/views/historyseries.tpl b/views/historyseries.tpl index 40dfdd1b7..a4da3dc43 100644 --- a/views/historyseries.tpl +++ b/views/historyseries.tpl @@ -102,6 +102,7 @@ % upgradable_criteria = (row[7], row[4], row[10]) % if upgradable_criteria in upgradable_episodes: + % if row[8] != "None": % if row[9] in ast.literal_eval(str(row[8])):
{{row[5]}} @@ -109,6 +110,7 @@ % else: {{row[5]}} % end + % end % else: {{row[5]}} %end