Fix for upgrade that is not taking into account the monitored status when download only monitored is enabled.

pull/551/head
Louis Vézina 5 years ago
parent e2b83152a3
commit 41e04023d9

@ -979,6 +979,16 @@ def upgrade_subtitles():
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) - minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
datetime(1970, 1, 1)).total_seconds() datetime(1970, 1, 1)).total_seconds()
if settings.sonarr.getboolean('only_monitored'):
series_monitored_only_query_string = ' AND table_episodes.monitored = "True"'
else:
series_monitored_only_query_string = ""
if settings.radarr.getboolean('only_monitored'):
movies_monitored_only_query_string = ' AND table_movies.monitored = "True"'
else:
movies_monitored_only_query_string = ""
if settings.general.getboolean('upgrade_manual'): if settings.general.getboolean('upgrade_manual'):
query_actions = [1, 2, 3] query_actions = [1, 2, 3]
else: else:
@ -994,7 +1004,7 @@ def upgrade_subtitles():
INNER JOIN table_shows on table_shows.sonarrSeriesId = table_history.sonarrSeriesId INNER JOIN table_shows on table_shows.sonarrSeriesId = table_history.sonarrSeriesId
INNER JOIN table_episodes on table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId INNER JOIN table_episodes on table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId
WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp > ? AND WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp > ? AND
score is not null score is not null""" + series_monitored_only_query_string + """
GROUP BY table_history.video_path, table_history.language""", GROUP BY table_history.video_path, table_history.language""",
(minimum_timestamp,)).fetchall() (minimum_timestamp,)).fetchall()
movies_list = c.execute("""SELECT table_history_movie.video_path, table_history_movie.language, movies_list = c.execute("""SELECT table_history_movie.video_path, table_history_movie.language,
@ -1004,7 +1014,7 @@ def upgrade_subtitles():
FROM table_history_movie FROM table_history_movie
INNER JOIN table_movies on table_movies.radarrId = table_history_movie.radarrId INNER JOIN table_movies on table_movies.radarrId = table_history_movie.radarrId
WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp > ? AND WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp > ? AND
score is not null score is not null""" + movies_monitored_only_query_string + """
GROUP BY table_history_movie.video_path, table_history_movie.language""", GROUP BY table_history_movie.video_path, table_history_movie.language""",
(minimum_timestamp,)).fetchall() (minimum_timestamp,)).fetchall()
db.close() db.close()

@ -999,6 +999,11 @@ def historyseries():
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) - minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
datetime(1970, 1, 1)).total_seconds() datetime(1970, 1, 1)).total_seconds()
if settings.sonarr.getboolean('only_monitored'):
series_monitored_only_query_string = ' AND table_episodes.monitored = "True"'
else:
series_monitored_only_query_string = ""
if settings.general.getboolean('upgrade_manual'): if settings.general.getboolean('upgrade_manual'):
query_actions = [1, 2, 3] query_actions = [1, 2, 3]
else: else:
@ -1006,8 +1011,10 @@ def historyseries():
upgradable_episodes = c.execute("""SELECT video_path, MAX(timestamp), score upgradable_episodes = c.execute("""SELECT video_path, MAX(timestamp), score
FROM table_history FROM table_history
INNER JOIN table_episodes on table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId
WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND
timestamp > ? AND score is not null timestamp > ? AND score is not null""" +
series_monitored_only_query_string + """
GROUP BY table_history.video_path, table_history.language""", GROUP BY table_history.video_path, table_history.language""",
(minimum_timestamp,)).fetchall() (minimum_timestamp,)).fetchall()
for upgradable_episode in upgradable_episodes: for upgradable_episode in upgradable_episodes:
@ -1072,6 +1079,11 @@ def historymovies():
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) - minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
datetime(1970, 1, 1)).total_seconds() datetime(1970, 1, 1)).total_seconds()
if settings.radarr.getboolean('only_monitored'):
movies_monitored_only_query_string = ' AND table_movies.monitored = "True"'
else:
movies_monitored_only_query_string = ""
if settings.general.getboolean('upgrade_manual'): if settings.general.getboolean('upgrade_manual'):
query_actions = [1, 2, 3] query_actions = [1, 2, 3]
else: else:
@ -1079,8 +1091,10 @@ def historymovies():
upgradable_movies = c.execute("""SELECT video_path, MAX(timestamp), score upgradable_movies = c.execute("""SELECT video_path, MAX(timestamp), score
FROM table_history_movie 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 WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND
timestamp > ? AND score is not null timestamp > ? AND score is not null""" +
movies_monitored_only_query_string + """
GROUP BY video_path, language""", GROUP BY video_path, language""",
(minimum_timestamp,)).fetchall() (minimum_timestamp,)).fetchall()
for upgradable_movie in upgradable_movies: for upgradable_movie in upgradable_movies:

Loading…
Cancel
Save