Continuing development.

This commit is contained in:
Louis Vézina 2019-05-10 09:24:11 -04:00
parent 0d384be7e3
commit 2abf522d1f
4 changed files with 78 additions and 29 deletions

View File

@ -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]

View File

@ -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()

View File

@ -87,18 +87,26 @@
<td>
% 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])):
<div class="ui inverted basic compact icon" data-tooltip="This subtitles is eligible to an upgrade." data-inverted="" data-position="top left">
<i class="ui green recycle icon upgrade"></i>{{row[3]}}
</div>
% 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:
<div class="ui inverted basic compact icon" data-tooltip="This subtitles is eligible to an upgrade." data-inverted="" data-position="top left">
<i class="ui green recycle icon upgrade"></i>{{row[3]}}
</div>
% else:
{{row[3]}}
% end
% end
% else:
{{row[3]}}
{{row[3]}}
% end
% end
% else:
{{row[3]}}
%end
</td>
</tr>
%end

View File

@ -102,18 +102,26 @@
<td>
% 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])):
<div class="ui inverted basic compact icon" data-tooltip="This subtitles is eligible to an upgrade." data-inverted="" data-position="top left">
<i class="ui green recycle icon upgrade"></i>{{row[5]}}
</div>
% 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:
<div class="ui inverted basic compact icon" data-tooltip="This subtitles is eligible to an upgrade." data-inverted="" data-position="top left">
<i class="ui green recycle icon upgrade"></i>{{row[5]}}
</div>
% else:
{{row[5]}}
% end
% end
% else:
{{row[5]}}
{{row[5]}}
% end
% end
% else:
{{row[5]}}
%end
</td>
</tr>
%end