diff --git a/bazarr/get_subtitle.py b/bazarr/get_subtitle.py index 2aa83bd6d..6419692dc 100644 --- a/bazarr/get_subtitle.py +++ b/bazarr/get_subtitle.py @@ -187,7 +187,7 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName, if subtitle.language == 'pt-BR': downloaded_language_code3 = 'pob' else: - downloaded_language_code3 = subtitle.language + downloaded_language_code3 = subtitle.language.alpha3 downloaded_language = language_from_alpha3(downloaded_language_code3) downloaded_language_code2 = alpha2_from_alpha3(downloaded_language_code3) downloaded_path = subtitle.storage_path @@ -374,7 +374,7 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a if saved_subtitle.language == 'pt-BR': downloaded_language_code3 = 'pob' else: - downloaded_language_code3 = subtitle.language + downloaded_language_code3 = subtitle.language.alpha3 downloaded_language = language_from_alpha3(downloaded_language_code3) downloaded_language_code2 = alpha2_from_alpha3(downloaded_language_code3) downloaded_path = saved_subtitle.storage_path @@ -736,7 +736,7 @@ def upgrade_subtitles(): INNER JOIN table_shows on table_shows.sonarrSeriesId = table_history.sonarrSeriesId INNER JOIN table_episodes on table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp > ? AND - score is not null AND score < "360" + score is not null GROUP BY table_history.video_path, table_history.language""", (minimum_timestamp,)).fetchall() movies_list = c.execute("""SELECT table_history_movie.video_path, table_history_movie.language, @@ -746,19 +746,19 @@ def upgrade_subtitles(): 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 AND score < "120" + score is not null GROUP BY table_history_movie.video_path, table_history_movie.language""", (minimum_timestamp,)).fetchall() db.close() episodes_to_upgrade = [] for episode in episodes_list: - if os.path.exists(path_replace(episode[0])): + if os.path.exists(path_replace(episode[0])) and int(episode[2]) < 360: episodes_to_upgrade.append(episode) movies_to_upgrade = [] for movie in movies_list: - if os.path.exists(path_replace_movie(movie[0])): + if os.path.exists(path_replace_movie(movie[0])) and int(movie[2]) < 120: movies_to_upgrade.append(movie) providers_list = get_providers() diff --git a/bazarr/main.py b/bazarr/main.py index 52835c96b..9a5c2b042 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -953,7 +953,7 @@ def historyseries(): today = [] thisweek = [] thisyear = [] - stats = c.execute("SELECT timestamp FROM table_history WHERE action LIKE '1'").fetchall() + stats = c.execute("SELECT timestamp FROM table_history WHERE action > 0").fetchall() total = len(stats) for stat in stats: if now - timedelta(hours=24) <= datetime.fromtimestamp(stat[0]) <= now: @@ -965,7 +965,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 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 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() @@ -980,12 +980,16 @@ def historyseries(): else: query_actions = [1, 3] - upgradable_episodes = c.execute("""SELECT table_history.video_path, MAX(table_history.timestamp) + upgradable_episodes = c.execute("""SELECT video_path, MAX(timestamp), score FROM table_history WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp > - ? AND score is not null AND score < "360" + ? AND score is not null GROUP BY table_history.video_path, table_history.language""", (minimum_timestamp,)).fetchall() + upgradable_episodes_not_perfect = [] + for upgradable_episode in upgradable_episodes: + if upgradable_episode[2] < "360": + upgradable_episodes_not_perfect.append(upgradable_episode) c.close() @@ -993,7 +997,7 @@ def historyseries(): return template('historyseries', bazarr_version=bazarr_version, rows=data, row_count=row_count, page=page, max_page=max_page, stats=stats, base_url=base_url, page_size=page_size, - current_port=settings.general.port, upgradable_episodes=upgradable_episodes) + current_port=settings.general.port, upgradable_episodes=upgradable_episodes_not_perfect) @route(base_url + 'historymovies') @@ -1017,7 +1021,7 @@ def historymovies(): today = [] thisweek = [] thisyear = [] - stats = c.execute("SELECT timestamp FROM table_history_movie WHERE action LIKE '1'").fetchall() + stats = c.execute("SELECT timestamp FROM table_history_movie WHERE action > 0").fetchall() total = len(stats) for stat in stats: if now - timedelta(hours=24) <= datetime.fromtimestamp(stat[0]) <= now: @@ -1029,7 +1033,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 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 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() @@ -1044,18 +1048,22 @@ def historymovies(): else: query_actions = [1, 3] - upgradable_movies = c.execute("""SELECT video_path, MAX(timestamp) + upgradable_movies = c.execute("""SELECT video_path, MAX(timestamp), score FROM table_history_movie WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp - > ? AND score is not null AND score < "120" + > ? AND score is not null GROUP BY video_path, language""", (minimum_timestamp,)).fetchall() + upgradable_movies_not_perfect = [] + for upgradable_movie in upgradable_movies: + if upgradable_movie[2] < "120": + upgradable_movies_not_perfect.append(upgradable_movie) c.close() data = reversed(sorted(data, key=operator.itemgetter(2))) return template('historymovies', bazarr_version=bazarr_version, rows=data, row_count=row_count, page=page, max_page=max_page, stats=stats, base_url=base_url, page_size=page_size, - current_port=settings.general.port, upgradable_movies=upgradable_movies) + current_port=settings.general.port, upgradable_movies=upgradable_movies_not_perfect) @route(base_url + 'wanted') diff --git a/views/historymovies.tpl b/views/historymovies.tpl index 01895b78e..6e764ed5f 100644 --- a/views/historymovies.tpl +++ b/views/historymovies.tpl @@ -85,7 +85,7 @@ - % upgradable_criteria = (row[5], row[2]) + % upgradable_criteria = (row[5], row[2], row[8]) % if upgradable_criteria in upgradable_movies: % if row[7] in ast.literal_eval(str(row[6])):
diff --git a/views/historyseries.tpl b/views/historyseries.tpl index 442793717..63a30bcda 100644 --- a/views/historyseries.tpl +++ b/views/historyseries.tpl @@ -100,7 +100,7 @@
- % upgradable_criteria = (row[7], row[4]) + % upgradable_criteria = (row[7], row[4], row[10]) % if upgradable_criteria in upgradable_episodes: % if row[9] in ast.literal_eval(str(row[8])):