From dd4d24fc3cfa1531f4eae6d6f27667b465acdc69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Fri, 31 Jan 2020 19:18:51 -0500 Subject: [PATCH] Fix for #789. --- bazarr/get_subtitle.py | 6 +++++- bazarr/main.py | 15 ++++++++++----- views/historymovies.tpl | 2 +- views/historyseries.tpl | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 698afd853..8b078f439 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -1010,7 +1010,7 @@ def upgrade_subtitles(): except ValueError: pass else: - if int(upgradable_movie['score']) < 360: + if int(upgradable_movie['score']) < 120: upgradable_movies_not_perfect.append(upgradable_movie) movies_to_upgrade = [] @@ -1025,6 +1025,8 @@ def upgrade_subtitles(): if settings.general.getboolean('use_sonarr'): for i, episode in enumerate(episodes_to_upgrade, 1): + if episode['languages'] in [None, 'None', '[]']: + continue providers = get_providers() if not providers: notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long') @@ -1074,6 +1076,8 @@ def upgrade_subtitles(): if settings.general.getboolean('use_radarr'): for i, movie in enumerate(movies_to_upgrade, 1): + if movie['languages'] in [None, 'None', '[]']: + continue providers = get_providers() if not providers: notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long') diff --git a/bazarr/main.py b/bazarr/main.py index f83f3697f..cac891428 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -999,15 +999,18 @@ def historyseries(): else: series_monitored_only_query_string = '' - upgradable_episodes = database.execute("SELECT video_path, MAX(timestamp) as timestamp, score FROM table_history " + upgradable_episodes = database.execute("SELECT video_path, MAX(timestamp) as timestamp, score, table_shows.languages FROM table_history " "INNER JOIN table_episodes on table_episodes.sonarrEpisodeId = " - "table_history.sonarrEpisodeId WHERE action IN (" + + "table_history.sonarrEpisodeId JOIN table_shows on table_shows.sonarrSeriesId = " + "table_history.sonarrSeriesId WHERE action IN (" + ','.join(map(str, query_actions)) + ") AND timestamp > ? AND " "score is not null" + series_monitored_only_query_string + " GROUP BY " "table_history.video_path, table_history.language", (minimum_timestamp,)) for upgradable_episode in upgradable_episodes: + if upgradable_episode['languages'] in [None, 'None', '[]']: + continue if upgradable_episode['timestamp'] > minimum_timestamp: try: int(upgradable_episode['score']) @@ -1076,15 +1079,17 @@ def historymovies(): else: query_actions = [1, 3] - upgradable_movies = database.execute("SELECT video_path, MAX(timestamp) as timestamp, score FROM table_history_movie " - "INNER JOIN table_movies on table_movies.radarrId=" - "table_history_movie.radarrId WHERE action IN (" + + upgradable_movies = database.execute("SELECT video_path, MAX(timestamp) as timestamp, score, " + "table_movies.languages FROM table_history_movie INNER JOIN table_movies " + "on table_movies.radarrId=table_history_movie.radarrId WHERE action IN (" + ','.join(map(str, query_actions)) + ") AND timestamp > ? AND score is not NULL" + movies_monitored_only_query_string + " GROUP BY video_path, language", (minimum_timestamp,)) for upgradable_movie in upgradable_movies: + if upgradable_movie['languages'] in [None, 'None', '[]']: + continue if upgradable_movie['timestamp'] > minimum_timestamp: try: int(upgradable_movie['score']) diff --git a/views/historymovies.tpl b/views/historymovies.tpl index a10411988..5aaec8090 100644 --- a/views/historymovies.tpl +++ b/views/historymovies.tpl @@ -89,7 +89,7 @@ - % upgradable_criteria = dict([('timestamp', row['timestamp']), ('video_path', row['video_path']), ('score', row['score'])]) + % upgradable_criteria = dict([('timestamp', row['timestamp']), ('video_path', row['video_path']), ('score', row['score']), ('languages', row['languages'])]) % if upgradable_criteria in upgradable_movies: % if row['languages'] != "None": % desired_languages = ast.literal_eval(str(row['languages'])) diff --git a/views/historyseries.tpl b/views/historyseries.tpl index 24a97f6d4..c30b086e5 100644 --- a/views/historyseries.tpl +++ b/views/historyseries.tpl @@ -104,7 +104,7 @@ - % upgradable_criteria = dict([('timestamp', row['timestamp']), ('video_path', row['path']), ('score', row['score'])]) + % upgradable_criteria = dict([('timestamp', row['timestamp']), ('video_path', row['path']), ('score', row['score']), ('languages', row['languages'])]) % if upgradable_criteria in upgradable_episodes: % if row['languages'] != "None": % desired_languages = ast.literal_eval(str(row['languages']))