Continuing development.

pull/380/head
Louis Vézina 6 years ago
parent dd17672593
commit f75f215081

@ -187,7 +187,7 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
if subtitle.language == 'pt-BR': if subtitle.language == 'pt-BR':
downloaded_language_code3 = 'pob' downloaded_language_code3 = 'pob'
else: else:
downloaded_language_code3 = subtitle.language downloaded_language_code3 = subtitle.language.alpha3
downloaded_language = language_from_alpha3(downloaded_language_code3) downloaded_language = language_from_alpha3(downloaded_language_code3)
downloaded_language_code2 = alpha2_from_alpha3(downloaded_language_code3) downloaded_language_code2 = alpha2_from_alpha3(downloaded_language_code3)
downloaded_path = subtitle.storage_path 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': if saved_subtitle.language == 'pt-BR':
downloaded_language_code3 = 'pob' downloaded_language_code3 = 'pob'
else: else:
downloaded_language_code3 = subtitle.language downloaded_language_code3 = subtitle.language.alpha3
downloaded_language = language_from_alpha3(downloaded_language_code3) downloaded_language = language_from_alpha3(downloaded_language_code3)
downloaded_language_code2 = alpha2_from_alpha3(downloaded_language_code3) downloaded_language_code2 = alpha2_from_alpha3(downloaded_language_code3)
downloaded_path = saved_subtitle.storage_path 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_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 AND score < "360" score is not null
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,
@ -746,19 +746,19 @@ 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 AND score < "120" score is not null
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()
episodes_to_upgrade = [] episodes_to_upgrade = []
for episode in episodes_list: 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) episodes_to_upgrade.append(episode)
movies_to_upgrade = [] movies_to_upgrade = []
for movie in movies_list: 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) movies_to_upgrade.append(movie)
providers_list = get_providers() providers_list = get_providers()

@ -953,7 +953,7 @@ def historyseries():
today = [] today = []
thisweek = [] thisweek = []
thisyear = [] 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) total = len(stats)
for stat in stats: for stat in stats:
if now - timedelta(hours=24) <= datetime.fromtimestamp(stat[0]) <= now: if now - timedelta(hours=24) <= datetime.fromtimestamp(stat[0]) <= now:
@ -965,7 +965,7 @@ def historyseries():
stats = [len(today), len(thisweek), len(thisyear), total] stats = [len(today), len(thisweek), len(thisyear), total]
c.execute( 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,)) (page_size, offset,))
data = c.fetchall() data = c.fetchall()
@ -980,12 +980,16 @@ def historyseries():
else: else:
query_actions = [1, 3] 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 FROM table_history
WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp > 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""", GROUP BY table_history.video_path, table_history.language""",
(minimum_timestamp,)).fetchall() (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() c.close()
@ -993,7 +997,7 @@ def historyseries():
return template('historyseries', bazarr_version=bazarr_version, rows=data, row_count=row_count, 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, 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') @route(base_url + 'historymovies')
@ -1017,7 +1021,7 @@ def historymovies():
today = [] today = []
thisweek = [] thisweek = []
thisyear = [] 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) total = len(stats)
for stat in stats: for stat in stats:
if now - timedelta(hours=24) <= datetime.fromtimestamp(stat[0]) <= now: if now - timedelta(hours=24) <= datetime.fromtimestamp(stat[0]) <= now:
@ -1029,7 +1033,7 @@ def historymovies():
stats = [len(today), len(thisweek), len(thisyear), total] stats = [len(today), len(thisweek), len(thisyear), total]
c.execute( 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,)) (page_size, offset,))
data = c.fetchall() data = c.fetchall()
@ -1044,18 +1048,22 @@ def historymovies():
else: else:
query_actions = [1, 3] 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 FROM table_history_movie
WHERE action IN (""" + ','.join(map(str, query_actions)) + """) AND timestamp 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""", GROUP BY video_path, language""",
(minimum_timestamp,)).fetchall() (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() c.close()
data = reversed(sorted(data, key=operator.itemgetter(2))) data = reversed(sorted(data, key=operator.itemgetter(2)))
return template('historymovies', bazarr_version=bazarr_version, rows=data, row_count=row_count, 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, 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') @route(base_url + 'wanted')

@ -85,7 +85,7 @@
</div> </div>
</td> </td>
<td> <td>
% upgradable_criteria = (row[5], row[2]) % upgradable_criteria = (row[5], row[2], row[8])
% if upgradable_criteria in upgradable_movies: % if upgradable_criteria in upgradable_movies:
% if row[7] in ast.literal_eval(str(row[6])): % if 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"> <div class="ui inverted basic compact icon" data-tooltip="This subtitles is eligible to an upgrade." data-inverted="" data-position="top left">

@ -100,7 +100,7 @@
</div> </div>
</td> </td>
<td> <td>
% upgradable_criteria = (row[7], row[4]) % upgradable_criteria = (row[7], row[4], row[10])
% if upgradable_criteria in upgradable_episodes: % if upgradable_criteria in upgradable_episodes:
% if row[9] in ast.literal_eval(str(row[8])): % 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"> <div class="ui inverted basic compact icon" data-tooltip="This subtitles is eligible to an upgrade." data-inverted="" data-position="top left">

Loading…
Cancel
Save