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

This commit is contained in:
Louis Vézina 2019-08-29 11:24:34 -04:00
parent e2b83152a3
commit 41e04023d9
2 changed files with 31 additions and 7 deletions

View file

@ -979,6 +979,16 @@ def upgrade_subtitles():
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
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'):
query_actions = [1, 2, 3]
else:
@ -994,7 +1004,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
score is not null""" + series_monitored_only_query_string + """
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,
@ -1004,7 +1014,7 @@ 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
score is not null""" + movies_monitored_only_query_string + """
GROUP BY table_history_movie.video_path, table_history_movie.language""",
(minimum_timestamp,)).fetchall()
db.close()

View file

@ -999,6 +999,11 @@ def historyseries():
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
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'):
query_actions = [1, 2, 3]
else:
@ -1006,8 +1011,10 @@ def historyseries():
upgradable_episodes = c.execute("""SELECT video_path, MAX(timestamp), score
FROM table_history
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
timestamp > ? AND score is not null""" +
series_monitored_only_query_string + """
GROUP BY table_history.video_path, table_history.language""",
(minimum_timestamp,)).fetchall()
for upgradable_episode in upgradable_episodes:
@ -1072,6 +1079,11 @@ def historymovies():
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
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'):
query_actions = [1, 2, 3]
else:
@ -1079,8 +1091,10 @@ def historymovies():
upgradable_movies = c.execute("""SELECT video_path, MAX(timestamp), score
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
timestamp > ? AND score is not null""" +
movies_monitored_only_query_string + """
GROUP BY video_path, language""",
(minimum_timestamp,)).fetchall()
for upgradable_movie in upgradable_movies: