diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index d4e44d98c..bd3076535 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -849,12 +849,29 @@ def upgrade_subtitles(): if settings.general.getboolean('use_sonarr'): for i, episode in enumerate(episodes_to_upgrade, 1): if episode[9] != "None": - if episode[1] in ast.literal_eval(str(episode[9])): + desired_languages = ast.literal_eval(str(episode[9])) + if episode[10] == "True": + forced_languages = [l + ":forced" for l in desired_languages] + elif episode[10] == "Both": + forced_languages = [l + ":forced" for l in desired_languages] + desired_languages + else: + forced_languages = desired_languages + + if episode[1] in forced_languages: 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 episode[1].endswith('forced'): + language = episode[1].split(':')[0] + is_forced = "True" + else: + language = episode[1] + is_forced = "False" + + result = download_subtitle(path_replace(episode[0]), str(alpha3_from_alpha2(language)), + episode[3], is_forced, 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] @@ -869,11 +886,27 @@ def upgrade_subtitles(): if settings.general.getboolean('use_radarr'): for i, movie in enumerate(movies_to_upgrade, 1): if movie[8] != "None": - if movie[1] in ast.literal_eval(str(movie[8])): + desired_languages = ast.literal_eval(str(movie[8])) + if movie[9] == "True": + forced_languages = [l + ":forced" for l in desired_languages] + elif movie[9] == "Both": + forced_languages = [l + ":forced" for l in desired_languages] + desired_languages + else: + forced_languages = desired_languages + + if movie[1] in forced_languages: 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]), + + if movie[1].endswith('forced'): + language = movie[1].split(':')[0] + is_forced = "True" + else: + language = movie[1] + is_forced = "False" + + result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(language)), + movie[3], is_forced, 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] diff --git a/bazarr/main.py b/bazarr/main.py index 476304eb9..e7f5783ad 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -966,7 +966,7 @@ def historyseries(): stats = [len(today), len(thisweek), len(thisyear), total] c.execute( - "SELECT table_history.action, table_shows.title, table_episodes.season || 'x' || table_episodes.episode, table_episodes.title, table_history.timestamp, table_history.description, table_history.sonarrSeriesId, table_episodes.path, table_shows.languages, table_history.language, table_history.score FROM table_history LEFT JOIN table_shows on table_shows.sonarrSeriesId = table_history.sonarrSeriesId LEFT JOIN table_episodes on table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId ORDER BY id DESC LIMIT ? OFFSET ?", + "SELECT table_history.action, table_shows.title, table_episodes.season || 'x' || table_episodes.episode, table_episodes.title, table_history.timestamp, table_history.description, table_history.sonarrSeriesId, table_episodes.path, table_shows.languages, table_history.language, table_history.score, table_shows.forced FROM table_history LEFT JOIN table_shows on table_shows.sonarrSeriesId = table_history.sonarrSeriesId LEFT JOIN table_episodes on table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId ORDER BY id DESC LIMIT ? OFFSET ?", (page_size, offset,)) data = c.fetchall() @@ -1039,7 +1039,7 @@ def historymovies(): stats = [len(today), len(thisweek), len(thisyear), total] c.execute( - "SELECT table_history_movie.action, table_movies.title, table_history_movie.timestamp, table_history_movie.description, table_history_movie.radarrId, table_history_movie.video_path, table_movies.languages, table_history_movie.language, table_history_movie.score FROM table_history_movie LEFT JOIN table_movies on table_movies.radarrId = table_history_movie.radarrId ORDER BY id DESC LIMIT ? OFFSET ?", + "SELECT table_history_movie.action, table_movies.title, table_history_movie.timestamp, table_history_movie.description, table_history_movie.radarrId, table_history_movie.video_path, table_movies.languages, table_history_movie.language, table_history_movie.score, table_movies.forced FROM table_history_movie LEFT JOIN table_movies on table_movies.radarrId = table_history_movie.radarrId ORDER BY id DESC LIMIT ? OFFSET ?", (page_size, offset,)) data = c.fetchall() diff --git a/views/historymovies.tpl b/views/historymovies.tpl index 5f4e0d041..006f5b254 100644 --- a/views/historymovies.tpl +++ b/views/historymovies.tpl @@ -87,18 +87,26 @@ % 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]}} -
+ % if row[6] != "None": + % desired_languages = ast.literal_eval(str(row[6])) + % if row[9] == "True": + % forced_languages = [l + ":forced" for l in desired_languages] + % elif row[9] == "Both": + % forced_languages = [l + ":forced" for l in desired_languages] + desired_languages + % else: + % forced_languages = desired_languages + % end + % if row[6] and row[7] and row[7] in forced_languages: +
+ {{row[3]}} +
+ % else: + {{row[3]}} + % end + % end % else: - {{row[3]}} - % end + {{row[3]}} % end - % else: - {{row[3]}} - %end %end diff --git a/views/historyseries.tpl b/views/historyseries.tpl index a4da3dc43..555b98c30 100644 --- a/views/historyseries.tpl +++ b/views/historyseries.tpl @@ -102,18 +102,26 @@ % 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]}} -
+ % if row[8] != "None": + % desired_languages = ast.literal_eval(str(row[8])) + % if row[11] == "True": + % forced_languages = [l + ":forced" for l in desired_languages] + % elif row[11] == "Both": + % forced_languages = [l + ":forced" for l in desired_languages] + desired_languages + % else: + % forced_languages = desired_languages + % end + % if row[9] in forced_languages: +
+ {{row[5]}} +
+ % else: + {{row[5]}} + % end + % end % else: - {{row[5]}} - % end + {{row[5]}} % end - % else: - {{row[5]}} - %end %end