Merge branch 'morpheus' into development

This commit is contained in:
Louis Vézina 2019-03-21 20:28:14 -04:00
commit db69b721b2
12 changed files with 461 additions and 36 deletions

View File

@ -33,11 +33,14 @@ defaults = {
'use_embedded_subs': 'True',
'adaptive_searching': 'False',
'enabled_providers': '',
'throtteled_providers': '',
'throtteled_providers': '{}',
'multithreading': 'True',
'chmod': '0640',
'subfolder': 'current',
'subfolder_custom': ''
'subfolder_custom': '',
'upgrade_subs': 'True',
'days_to_upgrade_subs': '7',
'upgrade_manual': 'True'
},
'auth': {
'type': 'None',

View File

@ -3,6 +3,7 @@ import os
import datetime
import logging
import subliminal_patch
import pretty
from get_args import args
from config import settings
@ -139,3 +140,33 @@ def provider_throttle(name, exception):
logging.info("Throttling %s for %s, until %s, because of: %s. Exception info: %r", name, throttle_description,
throttle_until.strftime("%y/%m/%d %H:%M"), cls_name, exception.message)
def update_throttled_provider():
changed = False
if settings.general.enabled_providers:
for provider in settings.general.enabled_providers.lower().split(','):
reason, until, throttle_desc = tp.get(provider, (None, None, None))
if reason:
now = datetime.datetime.now()
if now < until:
pass
else:
logging.info("Using %s again after %s, (disabled because: %s)", provider, throttle_desc, reason)
del tp[provider]
settings.general.throtteled_providers = str(tp)
changed = True
if changed:
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)
def list_throttled_providers():
update_throttled_provider()
throttled_providers = []
if settings.general.enabled_providers:
for provider in settings.general.enabled_providers.lower().split(','):
reason, until, throttle_desc = tp.get(provider, (None, None, None))
throttled_providers.append([provider, reason, pretty.date(until)])
return throttled_providers

View File

@ -102,7 +102,7 @@ def get_scores(video, media_type, min_score_movie_perc=60 * 100 / 120.0, min_sco
return min_score, max_score, set(scores)
def download_subtitle(path, language, hi, providers, providers_auth, sceneName, title, media_type):
def download_subtitle(path, language, hi, providers, providers_auth, sceneName, title, media_type, forced_minimum_score=None, is_upgrade=False):
# fixme: supply all missing languages, not only one, to hit providers only once who support multiple languages in
# one query
@ -112,7 +112,7 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
else:
hi = False
language_set = set()
if not isinstance(language, types.ListType):
language = [language]
@ -145,6 +145,8 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
min_score_series_perc=int(minimum_score))
if providers:
if forced_minimum_score:
min_score = int(forced_minimum_score) + 1
downloaded_subtitles = download_best_subtitles({video}, language_set, int(min_score), hi,
providers=providers,
provider_configs=providers_auth,
@ -183,16 +185,23 @@ def download_subtitle(path, language, hi, providers, providers_auth, sceneName,
saved_any = True
for subtitle in saved_subtitles:
downloaded_provider = subtitle.provider_name
downloaded_language = language_from_alpha3(subtitle.language.alpha3)
downloaded_language_code2 = alpha2_from_alpha3(subtitle.language.alpha3)
downloaded_language_code3 = subtitle.language.alpha3
if subtitle.language == 'pt-BR':
downloaded_language_code3 = 'pob'
else:
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
logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path)
if is_upgrade:
action = "upgraded"
else:
action = "downloaded"
if video.used_scene_name:
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(
message = downloaded_language + " subtitles " + action + " from " + downloaded_provider + " with a score of " + unicode(
round(subtitle.score * 100 / max_score, 2)) + "% using this scene name: " + sceneName
else:
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(
message = downloaded_language + " subtitles " + action + " from " + downloaded_provider + " with a score of " + unicode(
round(subtitle.score * 100 / max_score, 2)) + "% using filename guessing."
if use_postprocessing is True:
@ -367,9 +376,12 @@ def manual_download_subtitle(path, language, hi, subtitle, provider, providers_a
if saved_subtitles:
for saved_subtitle in saved_subtitles:
downloaded_provider = saved_subtitle.provider_name
downloaded_language = language_from_alpha3(saved_subtitle.language.alpha3)
downloaded_language_code2 = alpha2_from_alpha3(saved_subtitle.language.alpha3)
downloaded_language_code3 = saved_subtitle.language.alpha3
if saved_subtitle.language == 'pt-BR':
downloaded_language_code3 = 'pob'
else:
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
logging.debug('BAZARR Subtitles file saved to disk: ' + downloaded_path)
message = downloaded_language + " subtitles downloaded from " + downloaded_provider + " with a score of " + unicode(
@ -707,3 +719,88 @@ def refine_from_db(path, video):
if data[6]: video.audio_codec = data[6]
return video
def upgrade_subtitles():
days_to_upgrade_subs = settings.general.days_to_upgrade_subs
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
datetime(1970, 1, 1)).total_seconds()
if settings.general.getboolean('upgrade_manual'):
query_actions = [1, 2, 3]
else:
query_actions = [1, 3]
db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
c = db.cursor()
episodes_list = c.execute("""SELECT table_history.video_path, table_history.language, table_history.score,
table_shows.hearing_impaired, table_episodes.scene_name, table_episodes.title,
table_episodes.sonarrSeriesId, table_episodes.sonarrEpisodeId,
MAX(table_history.timestamp), table_shows.languages
FROM table_history
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
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,
table_history_movie.score, table_movies.hearing_impaired, table_movies.sceneName,
table_movies.title, table_movies.radarrId, MAX(table_history_movie.timestamp),
table_movies.languages
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
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])) 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])) and int(movie[2]) < 120:
movies_to_upgrade.append(movie)
providers_list = get_providers()
providers_auth = get_providers_auth()
for episode in episodes_to_upgrade:
if episode[1] in ast.literal_eval(str(episode[9])):
notifications.write(
msg='Searching to upgrade ' + str(language_from_alpha2(episode[1])) + ' subtitles for this episode: ' +
path_replace(episode[0]), queue='get_subtitle')
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 result is not None:
message = result[0]
path = result[1]
language_code = result[2]
provider = result[3]
score = result[4]
store_subtitles(path_replace(episode[0]))
history_log(3, episode[6], episode[7], message, path, language_code, provider, score)
send_notifications(episode[6], episode[7], message)
for movie in movies_to_upgrade:
if movie[1] in ast.literal_eval(str(movie[8])):
notifications.write(
msg='Searching to upgrade ' + str(language_from_alpha2(movie[1])) + ' subtitles for this movie: ' +
path_replace_movie(movie[0]), queue='get_subtitle')
result = download_subtitle(path_replace_movie(movie[0]), str(alpha3_from_alpha2(movie[1])),
movie[3], 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]
path = result[1]
language_code = result[2]
provider = result[3]
score = result[4]
store_subtitles_movie(path_replace_movie(movie[0]))
history_log_movie(3, movie[6], message, path, language_code, provider, score)
send_notifications_movie(movie[6], message)

View File

@ -53,7 +53,7 @@ from cork import Cork
from bottle import route, run, template, static_file, request, redirect, response, HTTPError, app, hook, abort
from datetime import datetime, timedelta
from get_languages import load_language_in_db, language_from_alpha3
from get_providers import get_providers, get_providers_auth
from get_providers import get_providers, get_providers_auth, list_throttled_providers
from get_series import *
from get_episodes import *
@ -62,7 +62,7 @@ if not args.no_update:
from list_subtitles import store_subtitles, store_subtitles_movie, series_scan_subtitles, movies_scan_subtitles, \
list_missing_subtitles, list_missing_subtitles_movies
from get_subtitle import download_subtitle, series_download_subtitles, movies_download_subtitles, \
wanted_download_subtitles, wanted_search_missing_subtitles, manual_search, manual_download_subtitle
wanted_download_subtitles, wanted_search_missing_subtitles, manual_search, manual_download_subtitle, upgrade_subtitles
from utils import history_log, history_log_movie
from scheduler import *
from notifier import send_notifications, send_notifications_movie
@ -278,7 +278,18 @@ def save_wizard():
settings_general_embedded = 'True'
settings_subfolder = request.forms.get('settings_subfolder')
settings_subfolder_custom = request.forms.get('settings_subfolder_custom')
settings_upgrade_subs = request.forms.get('settings_upgrade_subs')
if settings_upgrade_subs is None:
settings_upgrade_subs = 'False'
else:
settings_upgrade_subs = 'True'
settings_days_to_upgrade_subs = request.forms.get('settings_days_to_upgrade_subs')
settings_upgrade_manual = request.forms.get('settings_upgrade_manual')
if settings_upgrade_manual is None:
settings_upgrade_manual = 'False'
else:
settings_upgrade_manual = 'True'
settings.general.ip = text_type(settings_general_ip)
settings.general.port = text_type(settings_general_port)
settings.general.base_url = text_type(settings_general_baseurl)
@ -290,7 +301,10 @@ def save_wizard():
settings.general.subfolder = text_type(settings_subfolder)
settings.general.subfolder_custom = text_type(settings_subfolder_custom)
settings.general.use_embedded_subs = text_type(settings_general_embedded)
settings.general.upgrade_subs = text_type(settings_upgrade_subs)
settings.general.days_to_upgrade_subs = text_type(settings_days_to_upgrade_subs)
settings.general.upgrade_manual = text_type(settings_upgrade_manual)
settings_sonarr_ip = request.forms.get('settings_sonarr_ip')
settings_sonarr_port = request.forms.get('settings_sonarr_port')
settings_sonarr_baseurl = request.forms.get('settings_sonarr_baseurl')
@ -939,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:
@ -951,14 +965,44 @@ 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 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()
upgradable_episodes = []
if settings.general.getboolean('upgrade_subs'):
days_to_upgrade_subs = settings.general.days_to_upgrade_subs
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
datetime(1970, 1, 1)).total_seconds()
if settings.general.getboolean('upgrade_manual'):
query_actions = [1, 2, 3]
else:
query_actions = [1, 3]
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
GROUP BY table_history.video_path, table_history.language""",
(minimum_timestamp,)).fetchall()
upgradable_episodes_not_perfect = []
for upgradable_episode in upgradable_episodes:
try:
int(upgradable_episode[2])
except ValueError:
pass
else:
if int(upgradable_episode[2]) < 360:
upgradable_episodes_not_perfect.append(upgradable_episode)
c.close()
data = reversed(sorted(data, key=operator.itemgetter(4)))
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)
current_port=settings.general.port, upgradable_episodes=upgradable_episodes_not_perfect)
@route(base_url + 'historymovies')
@ -982,7 +1026,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:
@ -994,14 +1038,42 @@ 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 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()
upgradable_movies = []
if settings.general.getboolean('upgrade_subs'):
days_to_upgrade_subs = settings.general.days_to_upgrade_subs
minimum_timestamp = ((datetime.now() - timedelta(days=int(days_to_upgrade_subs))) -
datetime(1970, 1, 1)).total_seconds()
if settings.general.getboolean('upgrade_manual'):
query_actions = [1, 2, 3]
else:
query_actions = [1, 3]
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
GROUP BY video_path, language""",
(minimum_timestamp,)).fetchall()
upgradable_movies_not_perfect = []
for upgradable_movie in upgradable_movies:
try:
int(upgradable_movie[2])
except ValueError:
pass
else:
if int(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)
current_port=settings.general.port, upgradable_movies=upgradable_movies_not_perfect)
@route(base_url + 'wanted')
@ -1187,7 +1259,18 @@ def save_settings():
settings_page_size = request.forms.get('settings_page_size')
settings_subfolder = request.forms.get('settings_subfolder')
settings_subfolder_custom = request.forms.get('settings_subfolder_custom')
settings_upgrade_subs = request.forms.get('settings_upgrade_subs')
if settings_upgrade_subs is None:
settings_upgrade_subs = 'False'
else:
settings_upgrade_subs = 'True'
settings_days_to_upgrade_subs = request.forms.get('settings_days_to_upgrade_subs')
settings_upgrade_manual = request.forms.get('settings_upgrade_manual')
if settings_upgrade_manual is None:
settings_upgrade_manual = 'False'
else:
settings_upgrade_manual = 'True'
before = (unicode(settings.general.ip), int(settings.general.port), unicode(settings.general.base_url),
unicode(settings.general.path_mappings), unicode(settings.general.getboolean('use_sonarr')),
unicode(settings.general.getboolean('use_radarr')), unicode(settings.general.path_mappings_movie))
@ -1214,6 +1297,9 @@ def save_settings():
settings.general.page_size = text_type(settings_page_size)
settings.general.subfolder = text_type(settings_subfolder)
settings.general.subfolder_custom = text_type(settings_subfolder_custom)
settings.general.upgrade_subs = text_type(settings_upgrade_subs)
settings.general.days_to_upgrade_subs = text_type(settings_days_to_upgrade_subs)
settings.general.upgrade_manual = text_type(settings_upgrade_manual)
settings.general.minimum_score_movie = text_type(settings_general_minimum_score_movies)
settings.general.use_embedded_subs = text_type(settings_general_embedded)
settings.general.adaptive_searching = text_type(settings_general_adaptive_searching)
@ -1556,6 +1642,8 @@ def system():
elif job.trigger.__str__().startswith('cron'):
task_list.append([job.name, get_time_from_cron(job.trigger.fields), next_run, job.id])
throttled_providers = list_throttled_providers()
i = 0
with open(os.path.join(args.config_dir, 'log', 'bazarr.log')) as f:
for i, l in enumerate(f, 1):
@ -1592,7 +1680,7 @@ def system():
operating_system=platform.platform(), python_version=platform.python_version(),
config_dir=args.config_dir, bazarr_dir=os.path.normcase(os.getcwd()),
base_url=base_url, task_list=task_list, row_count=row_count, max_page=max_page, page_size=page_size,
releases=releases, current_port=settings.general.port)
releases=releases, current_port=settings.general.port, throttled_providers=throttled_providers)
@route(base_url + 'logs/<page:int>')
@ -1743,7 +1831,7 @@ def manual_get_subtitle():
language_code = result[2]
provider = result[3]
score = result[4]
history_log(1, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
history_log(2, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
store_subtitles(unicode(episodePath))
list_missing_subtitles(sonarrSeriesId)
@ -1832,7 +1920,7 @@ def manual_get_subtitle_movie():
language_code = result[2]
provider = result[3]
score = result[4]
history_log_movie(1, radarrId, message, path, language_code, provider, score)
history_log_movie(2, radarrId, message, path, language_code, provider, score)
send_notifications_movie(radarrId, message)
store_subtitles_movie(unicode(moviePath))
list_missing_subtitles_movies(radarrId)

View File

@ -4,7 +4,7 @@ from get_episodes import sync_episodes, update_all_episodes, update_all_movies
from get_movies import update_movies
from get_series import update_series
from config import settings
from get_subtitle import wanted_search_missing_subtitles
from get_subtitle import wanted_search_missing_subtitles, upgrade_subtitles
from get_args import args
if not args.no_update:
@ -109,6 +109,10 @@ if settings.general.getboolean('use_sonarr') or settings.general.getboolean('use
scheduler.add_job(wanted_search_missing_subtitles, IntervalTrigger(hours=3), max_instances=1, coalesce=True,
misfire_grace_time=15, id='wanted_search_missing_subtitles', name='Search for wanted subtitles')
if settings.general.getboolean('upgrade_subs'):
scheduler.add_job(upgrade_subtitles, IntervalTrigger(hours=12), max_instances=1, coalesce=True,
misfire_grace_time=15, id='upgrade_subtitles', name='Upgrade previously downloaded subtitles')
sonarr_full_update()
radarr_full_update()
scheduler.start()

View File

@ -467,6 +467,9 @@
hi = $(this).attr("data-hi");
sonarrSeriesId = $(this).attr("data-sonarrSeriesId");
sonarrEpisodeId = $(this).attr("data-sonarrEpisodeId");
var languages = Array.from({{!subs_languages_list}});
var is_pb = languages.includes('pb');
var is_pt = languages.includes('pt');
const values = {
episodePath: episodePath,
@ -505,7 +508,15 @@
return data +'%';
}
},
{ data: 'language' },
{ data: null,
render: function ( data, type, row ) {
if ( data.language === "pt" && is_pb === true && is_pt === false) {
return 'pb'
} else {
return data.language
}
}
},
{ data: 'hearing_impaired' },
{ data: null,
render: function ( data, type, row ) {

View File

@ -52,6 +52,7 @@
</tr>
</thead>
<tbody>
%import ast
%import time
%import pretty
%for row in rows:
@ -65,6 +66,14 @@
<div class="ui inverted basic compact icon" data-tooltip="Subtitles file have been downloaded." data-inverted="" data-position="top left">
<i class="ui download icon"></i>
</div>
%elif row[0] == 2:
<div class="ui inverted basic compact icon" data-tooltip="Subtitles file have been manually downloaded." data-inverted="" data-position="top left">
<i class="ui user icon"></i>
</div>
%elif row[0] == 3:
<div class="ui inverted basic compact icon" data-tooltip="Subtitles file have been upgraded." data-inverted="" data-position="top left">
<i class="ui recycle icon"></i>
</div>
%end
</td>
<td>
@ -75,7 +84,20 @@
{{pretty.date(int(row[2]))}}
</div>
</td>
<td>{{row[3]}}</td>
<td>
% upgradable_criteria = (row[5], row[2], row[8])
% if upgradable_criteria in upgradable_movies:
% 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">
<i class="ui green recycle icon upgrade"></i>{{row[3]}}
</div>
% else:
{{row[3]}}
% end
% else:
{{row[3]}}
%end
</td>
</tr>
%end
</tbody>
@ -174,7 +196,7 @@
sessionStorage.clear();
}
$('a, i').on('click', function(){
$('a').on('click', function(){
sessionStorage.scrolly=$(window).scrollTop();
$('#loader').addClass('active');

View File

@ -54,6 +54,7 @@
</tr>
</thead>
<tbody>
%import ast
%import time
%import pretty
%for row in rows:
@ -67,6 +68,14 @@
<div class="ui inverted basic compact icon" data-tooltip="Subtitles file have been downloaded." data-inverted="" data-position="top left">
<i class="ui download icon"></i>
</div>
%elif row[0] == 2:
<div class="ui inverted basic compact icon" data-tooltip="Subtitles file have been manually downloaded." data-inverted="" data-position="top left">
<i class="ui user icon"></i>
</div>
%elif row[0] == 3:
<div class="ui inverted basic compact icon" data-tooltip="Subtitles file have been upgraded." data-inverted="" data-position="top left">
<i class="ui recycle icon"></i>
</div>
%end
</td>
<td>
@ -90,7 +99,20 @@
{{pretty.date(int(row[4]))}}
</div>
</td>
<td>{{row[5]}}</td>
<td>
% upgradable_criteria = (row[7], row[4], row[10])
% if upgradable_criteria in upgradable_episodes:
% 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>
% else:
{{row[5]}}
% end
% else:
{{row[5]}}
%end
</td>
</tr>
%end
</tbody>
@ -189,7 +211,7 @@
sessionStorage.clear();
}
$('a, i').on('click', function(){
$('a').on('click', function(){
sessionStorage.scrolly=$(window).scrollTop();
$('#loader').addClass('active');

View File

@ -25,7 +25,11 @@
</head>
<body>
% from get_args import args
% from get_providers import update_throttled_provider
% update_throttled_provider()
% import ast
% import datetime
% import os
% import sqlite3
% from config import settings
@ -46,7 +50,8 @@
% c = conn.cursor()
% wanted_series = c.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string_sonarr).fetchone()
% wanted_movies = c.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string_radarr).fetchone()
% from get_providers import list_throttled_providers
% throttled_providers_count = len(eval(str(settings.general.throtteled_providers)))
<div id="divmenu" class="ui container">
<div class="ui grid">
<div class="middle aligned row">
@ -96,7 +101,13 @@
Settings
</a>
<a class="item" href="{{base_url}}system">
<i class="laptop icon"></i>
<i class="laptop icon">
% if throttled_providers_count:
<div class="floating ui tiny yellow label" style="left:90% !important;top:0.5em !important;">
{{throttled_providers_count}}
</div>
% end
</i>
System
</a>
<a id="donate" class="item" href="https://beerpay.io/morpheus65535/bazarr">

View File

@ -416,6 +416,9 @@
language = $(this).attr("data-language");
hi = $(this).attr("data-hi");
radarrId = $(this).attr("data-radarrId");
var languages = Array.from({{!subs_languages_list}});
var is_pb = languages.includes('pb');
var is_pt = languages.includes('pt');
const values = {
moviePath: moviePath,
@ -453,7 +456,15 @@
return data +'%';
}
},
{ data: 'language' },
{ data: null,
render: function ( data, type, row ) {
if ( data.language === "pt" && is_pb === true && is_pt === false) {
return 'pb'
} else {
return data.language
}
}
},
{ data: 'hearing_impaired' },
{ data: null,
render: function ( data, type, row ) {

View File

@ -1081,6 +1081,7 @@
</div>
<div class="middle aligned row subfolder">
<div class="two wide column"></div>
<div class="right aligned four wide column">
<label>Custom Subtitle folder</label>
</div>
@ -1101,6 +1102,62 @@
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Upgrade previously downloaded subtitles</label>
</div>
<div class="one wide column">
<div id="settings_upgrade_subs" class="ui toggle checkbox" data-upgrade={{settings.general.getboolean('upgrade_subs')}}>
<input name="settings_upgrade_subs" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed center aligned column">
<div class="ui basic icon"
data-tooltip='Schedule a task that run every 12 hours to upgrade subtitles previously downloaded by Bazarr.'
data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
<div class="middle aligned row upgrade_subs">
<div class="two wide column"></div>
<div class="right aligned four wide column">
<label>Number of days to go back in history to upgrade subtitles (up to 30)</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
<input id="settings_days_to_upgrade_subs" name="settings_days_to_upgrade_subs"
type="text" pattern= "[0-9]" value="{{ settings.general.days_to_upgrade_subs }}">
</div>
</div>
</div>
</div>
<div class="middle aligned row upgrade_subs">
<div class="two wide column"></div>
<div class="right aligned four wide column">
<label>Upgrade manually downloaded subtitles</label>
</div>
<div class="one wide column">
<div id="settings_upgrade_manual" class="ui toggle checkbox" data-upgrade-manual={{settings.general.getboolean('upgrade_manual')}}>
<input name="settings_upgrade_manual" type="checkbox">
<label></label>
</div>
</div>
<div class="collapsed center aligned column">
<div class="ui basic icon"
data-tooltip='Enable or disable upgrade of manually searched and downloaded subtitles.'
data-inverted="">
<i class="help circle large icon"></i>
</div>
</div>
</div>
<div class="middle aligned row">
<div class="right aligned four wide column">
<label>Use embedded subtitles</label>
@ -2025,6 +2082,18 @@
$("#settings_scenename").checkbox('uncheck');
}
if ($('#settings_upgrade_subs').data("upgrade") === "True") {
$("#settings_upgrade_subs").checkbox('check');
} else {
$("#settings_upgrade_subs").checkbox('uncheck');
}
if ($('#settings_upgrade_manual').data("upgrade-manual") === "True") {
$("#settings_upgrade_manual").checkbox('check');
} else {
$("#settings_upgrade_manual").checkbox('uncheck');
}
if ($('#settings_embedded').data("embedded") === "True") {
$("#settings_embedded").checkbox('check');
} else {
@ -2148,6 +2217,21 @@
}
});
if ($('#settings_upgrade_subs').data("upgrade") === "True") {
$('.upgrade_subs').show();
} else {
$('.upgrade_subs').hide();
}
$('#settings_upgrade_subs').checkbox({
onChecked: function() {
$('.upgrade_subs').show();
},
onUnchecked: function() {
$('.upgrade_subs').hide();
}
});
if ($('#settings_auth_type').val() === "None") {
$('.auth_option').hide();
}
@ -2482,6 +2566,16 @@
type : 'empty'
}
]
},
settings_days_to_upgrade_subs : {
rules : [
{
type : 'integer[1..30]'
},
{
type : 'empty'
}
]
}
},
inline : true,

View File

@ -54,9 +54,18 @@
<div id="logout" class="ui icon button" data-tooltip="Logout" data-inverted=""><i class="sign-out icon"></i></div>
% end
</div>
<div class="ui top attached tabular menu">
% import datetime
% throttled_providers_count = len(eval(str(settings.general.throtteled_providers)))
<div class="ui top attached tabular menu">
<a class="tabs item active" data-tab="tasks">Tasks</a>
<a class="tabs item" data-tab="logs">Logs</a>
<a class="tabs item" data-tab="providers">Providers
% if throttled_providers_count:
<div class="ui tiny yellow label">
{{throttled_providers_count}}
</div>
% end
</a>
<a class="tabs item" data-tab="status">Status</a>
<a class="tabs item" data-tab="releases">Releases</a>
</div>
@ -120,6 +129,28 @@
%end
</div>
</div>
<div class="ui bottom attached tab segment" data-tab="providers">
<div class="content">
<table class="ui very basic table">
<thead>
<tr>
<th>Name</th>
<th>Status</th>
<th>Next retry</th>
</tr>
</thead>
<tbody>
%for provider in throttled_providers:
<tr>
<td>{{provider[0]}}</td>
<td>{{provider[1] if provider[1] is not None else "Good"}}</td>
<td>{{provider[2] if provider[2] is not "now" else "-"}}</td>
</tr>
%end
</tbody>
</table>
</div>
</div>
<div class="ui bottom attached tab segment" data-tab="status">
<div class="ui dividing header">About</div>
<div class="twelve wide column">