pull/884/head
Moravčík, Marian 5 years ago
parent 4282fe8f50
commit 7af7037c95

@ -136,6 +136,16 @@ def check_credentials(user, pw):
return False
@app.context_processor
def restart_processor():
def restart_required():
db = database.execute("SELECT configured, updated FROM system")
for i in db:
restart_required = i
return restart_required
return dict(restart_required=restart_required()['configured'], update_required=restart_required()['updated'], ast=ast, settings=settings)
def api_authorize():
if 'apikey' in request.GET.dict:
if request.GET.dict['apikey'][0] == settings.auth.apikey:
@ -153,7 +163,7 @@ def post_get(name, default=''):
@app.route(base_url + 'login/')
def login_form():
msg = request.query.get('msg', '')
return render_template('login', base_url=base_url, msg=msg)
return render_template('login.html', base_url=base_url, msg=msg)
@app.route(base_url + 'login/', methods=['POST'])
@ -174,7 +184,6 @@ def logout():
@app.route(base_url + 'shutdown/')
# @custom_auth_basic(check_credentials)
def shutdown():
try:
server.stop()
except:
@ -194,7 +203,6 @@ def shutdown():
@app.route(base_url + 'restart/')
# @custom_auth_basic(check_credentials)
def restart():
try:
server.stop()
except:
@ -215,8 +223,6 @@ def restart():
@app.route(base_url + 'wizard/')
@custom_auth_basic(check_credentials)
def wizard():
# Get languages list
settings_languages = database.execute("SELECT * FROM table_settings_languages ORDER BY name")
# Get providers list
@ -230,8 +236,6 @@ def wizard():
@app.route(base_url + 'save_wizard', methods=['POST'])
# @custom_auth_basic(check_credentials)
def save_wizard():
settings_general_ip = request.form.get('settings_general_ip')
settings_general_port = request.form.get('settings_general_port')
settings_general_baseurl = request.form.get('settings_general_baseurl')
@ -446,7 +450,6 @@ def save_wizard():
@app.route(base_url + 'emptylog')
# @custom_auth_basic(check_credentials)
def emptylog():
ref = request.environ['HTTP_REFERER']
empty_log()
@ -458,14 +461,12 @@ def emptylog():
@app.route(base_url + 'bazarr.log')
# @custom_auth_basic(check_credentials)
def download_log():
return static_file('bazarr.log', root=os.path.join(args.config_dir, 'log/'), download='bazarr.log')
@app.route(base_url + 'image_proxy/<path:url>', methods=['GET'])
# @custom_auth_basic(check_credentials)
def image_proxy(url):
apikey = settings.sonarr.apikey
url_image = url_sonarr_short() + '/' + url + '?apikey=' + apikey
try:
@ -483,7 +484,6 @@ def image_proxy(url):
@app.route(base_url + 'image_proxy_movies/<path:url>', methods=['GET'])
# @custom_auth_basic(check_credentials)
def image_proxy_movies(url):
apikey = settings.radarr.apikey
try:
url_image = (url_radarr_short() + '/' + url + '?apikey=' + apikey).replace('/fanart.jpg', '/banner.jpg')
@ -503,7 +503,6 @@ def image_proxy_movies(url):
@app.route(base_url)
# @custom_auth_basic(check_credentials)
def redirect_root():
if settings.general.getboolean('use_sonarr'):
return redirect(base_url + 'series')
elif settings.general.getboolean('use_radarr'):
@ -517,8 +516,6 @@ def redirect_root():
@app.route(base_url + 'series/')
# @custom_auth_basic(check_credentials)
def series():
series_count = database.execute("SELECT COUNT(*) as count FROM table_shows", only_one=True)['count']
page = request.data
if not page:
@ -564,7 +561,7 @@ def series():
"table_episodes.sonarrSeriesId WHERE table_shows.languages IS NOT 'None'"
+ total_subtitles_clause + " GROUP BY table_shows.sonarrSeriesId")
return render_template('series', bazarr_version=bazarr_version, rows=data, missing_subtitles_list=missing_subtitles_list,
return render_template('series.html', bazarr_version=bazarr_version, rows=data, missing_subtitles_list=missing_subtitles_list,
total_subtitles_list=total_subtitles_list, languages=languages, missing_count=series_count,
page=page, max_page=max_page, base_url=base_url,
single_language=settings.general.getboolean('single_language'), page_size=page_size,
@ -575,7 +572,6 @@ def series():
# @custom_auth_basic(check_credentials)
def serieseditor():
# Get missing count
missing_count = database.execute("SELECT COUNT(*) as count FROM table_shows", only_one=True)['count']
@ -588,7 +584,7 @@ def serieseditor():
# Get languages list
languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1")
return render_template('serieseditor', bazarr_version=bazarr_version, rows=data, languages=languages,
return render_template('serieseditor.html', bazarr_version=bazarr_version, rows=data, languages=languages,
missing_count=missing_count, base_url=base_url,
single_language=settings.general.getboolean('single_language'), current_port=settings.general.port)
@ -716,7 +712,7 @@ def episodes(no):
for key, season in itertools.groupby(episodes, lambda x: x['season']):
seasons_list.append(list(season))
return render_template('episodes', bazarr_version=bazarr_version, no=no, details=series_details,
return render_template('episodes.html', bazarr_version=bazarr_version, no=no, details=series_details,
languages=languages, seasons=seasons_list, url_sonarr_short=url_sonarr_short(), base_url=base_url,
tvdbid=tvdbid, number=number, current_port=settings.general.port)
@ -742,7 +738,7 @@ def movies():
languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1")
return render_template('movies', bazarr_version=bazarr_version, rows=data, languages=languages,
return render_template('movies.html', bazarr_version=bazarr_version, rows=data, languages=languages,
missing_count=missing_count, page=page, max_page=max_page, base_url=base_url,
single_language=settings.general.getboolean('single_language'), page_size=page_size,
current_port=settings.general.port)
@ -762,7 +758,7 @@ def movieseditor():
languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1")
return render_template('movieseditor', bazarr_version=bazarr_version, rows=data, languages=languages,
return render_template('movieseditor.html', bazarr_version=bazarr_version, rows=data, languages=languages,
missing_count=missing_count, base_url=base_url, single_language=
settings.general.getboolean('single_language'), current_port=settings.general.port)
@ -851,7 +847,7 @@ def movie(no):
languages = database.execute("SELECT code2, name FROM table_settings_languages WHERE enabled=1")
return render_template('movie', bazarr_version=bazarr_version, no=no, details=movies_details,
return render_template('movie.html', bazarr_version=bazarr_version, no=no, details=movies_details,
languages=languages, url_radarr_short=url_radarr_short(), base_url=base_url, tmdbid=tmdbid,
current_port=settings.general.port)
@ -915,7 +911,7 @@ def historyseries():
row_count = database.execute("SELECT COUNT(*) as count FROM table_history LEFT JOIN table_shows on "
"table_history.sonarrSeriesId = table_shows.sonarrSeriesId WHERE "
"table_shows.title is not NULL", only_one=True)['count']
page = request.args.page
page = request.data
if page == "":
page = "1"
page_size = int(settings.general.page_size)
@ -981,7 +977,7 @@ def historyseries():
if int(upgradable_episode['score']) < 360:
upgradable_episodes_not_perfect.append(upgradable_episode)
return render_template('historyseries', bazarr_version=bazarr_version, rows=data, row_count=row_count,
return render_template('historyseries.html', 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, upgradable_episodes=upgradable_episodes_not_perfect)
@ -994,7 +990,7 @@ def historymovies():
row_count = database.execute("SELECT COUNT(*) as count FROM table_history_movie LEFT JOIN table_movies ON "
"table_history_movie.radarrId=table_movies.radarrId "
"WHERE table_movies.title is not NULL", only_one=True)['count']
page = request.args.page
page = request.data
if page == "":
page = "1"
page_size = int(settings.general.page_size)
@ -1058,7 +1054,7 @@ def historymovies():
if int(upgradable_movie['score']) < 120:
upgradable_movies_not_perfect.append(upgradable_movie)
return render_template('historymovies', bazarr_version=bazarr_version, rows=data, row_count=row_count,
return render_template('historymovies.html', 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, upgradable_movies=upgradable_movies_not_perfect)
@ -1067,7 +1063,7 @@ def historymovies():
# @custom_auth_basic(check_credentials)
def wanted():
return render_template('wanted', bazarr_version=bazarr_version, base_url=base_url, current_port=settings.general.port)
return render_template('wanted.html', bazarr_version=bazarr_version, base_url=base_url, current_port=settings.general.port)
@app.route(base_url + 'wantedseries')
@ -1082,7 +1078,7 @@ def wantedseries():
missing_count = database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE missing_subtitles != '[]'" +
monitored_only_query_string, only_one=True)['count']
page = request.args.page
page = request.data
if page == "":
page = "1"
page_size = int(settings.general.page_size)
@ -1100,7 +1096,7 @@ def wantedseries():
# path_replace
dict_mapper.path_replace(data)
return render_template('wantedseries', bazarr_version=bazarr_version, rows=data, missing_count=missing_count, page=page,
return render_template('wantedseries.html', bazarr_version=bazarr_version, rows=data, missing_count=missing_count, page=page,
max_page=max_page, base_url=base_url, page_size=page_size, current_port=settings.general.port)
@ -1130,7 +1126,7 @@ def wantedmovies():
# path_replace
dict_mapper.path_replace_movie(data)
return render_template('wantedmovies', bazarr_version=bazarr_version, rows=data,
return render_template('wantedmovies.html', bazarr_version=bazarr_version, rows=data,
missing_count=missing_count, page=page, max_page=max_page, base_url=base_url, page_size=page_size,
current_port=settings.general.port)
@ -1381,29 +1377,6 @@ def save_settings():
settings.auth.type = text_type(settings_auth_type)
settings.auth.username = text_type(settings_auth_username)
settings.auth.password = hashlib.md5(settings_auth_password.encode('utf-8')).hexdigest()
if settings_auth_username not in aaa._store.users:
cork = Cork(os.path.normpath(os.path.join(args.config_dir, 'config')), initialize=True)
cork._store.roles[''] = 100
cork._store.save_roles()
cork._store.users[settings_auth_username] = {
'role': '',
'hash': cork._hash(settings_auth_username, settings_auth_password),
'email_addr': '',
'desc': '',
'creation_date': time.time()
}
cork._store.save_users()
if settings_auth_type == 'basic' or settings_auth_type == 'None':
pass
else:
aaa._beaker_session.delete()
else:
if settings.auth.password != settings_auth_password:
aaa.user(settings_auth_username).update(role='', pwd=settings_auth_password)
if settings_auth_type == 'basic' or settings_auth_type == 'None':
pass
else:
aaa._beaker_session.delete()
settings.auth.apikey = request.form.get('settings_auth_apikey')
settings_sonarr_ip = request.form.get('settings_sonarr_ip')
@ -1678,7 +1651,7 @@ def system():
page_size = int(settings.general.page_size)
return render_template('system', bazarr_version=bazarr_version,
return render_template('system.html', bazarr_version=bazarr_version,
sonarr_version=sonarr_version, radarr_version=radarr_version,
operating_system=platform.platform(), python_version=platform.python_version(),
config_dir=args.config_dir, bazarr_dir=os.path.normcase(os.path.dirname(os.path.dirname(__file__))),

@ -11,36 +11,48 @@
#divmenu {
padding-top: 1em;
}
.menu_segment {
padding: 0em !important;
border: none !important;
margin: 0em !important;
background: none !important;
}
#icon_menu {
background: transparent !important;
border: solid;
border-width: 1px;
border-color: white;
}
.prompt {
background-color: #333333 !important;
color: white !important;
border-radius: 3px !important;
}
.searchicon {
color: white !important;
}
.ui.progress .bar > .progress {
right: auto;
left: .5em;
color: black !important;
}
.ui.disabled.progress.notification_progress {
opacity: unset !important;
}
div.disabled { pointer-events: none; }
button.disabled { pointer-events: none; }
div.disabled {
pointer-events: none;
}
button.disabled {
pointer-events: none;
}
@media only screen and (max-width: 1024px) {
.logo {
@ -75,10 +87,12 @@
% monitored_only_query_string_radarr = ""
%end
% wanted_series = database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string_sonarr, only_one=True)['count']
% wanted_movies = database.execute("SELECT COUNT(*) as count FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string_radarr, only_one=True)['count']
% wanted_series = database.execute("SELECT COUNT(*) as count FROM table_episodes WHERE missing_subtitles != '[]'" +
monitored_only_query_string_sonarr, only_one=True)['count']
% wanted_movies = database.execute("SELECT COUNT(*) as count FROM table_movies WHERE missing_subtitles != '[]'" +
monitored_only_query_string_radarr, only_one=True)['count']
% from get_providers import list_throttled_providers
% throttled_providers_count = len(eval(str(settings.general.throtteled_providers)))
{% set throttled_providers_count = settings.general.throtteled_providers|length %}
<div id="divmenu" class="ui container">
<div class="ui grid">
<div class="three wide column">
@ -89,34 +103,36 @@
<div class="ten wide right aligned compact column">
<div id="button_menu" class="ui center aligned segment menu_segment" hidden="hidden">
<div class="ui inverted compact borderless labeled icon massive menu menu_segment">
% if settings.general.getboolean('use_sonarr'):
{% if settings.general.getboolean('use_sonarr') %}
<a class="item" href="{{ base_url }}series">
<i class="play icon"></i>
Series
</a>
% end
% if settings.general.getboolean('use_radarr'):
{% endif %}
{% if settings.general.getboolean('use_radarr') %}
<a class="item" href="{{ base_url }}movies">
<i class="film icon"></i>
Movies
</a>
% end
{% endif %}
<a class="item" href="{{ base_url }}history">
<i class="wait icon"></i>
History
</a>
<a class="item" href="{{ base_url }}wanted">
<i class="warning sign icon">
% if settings.general.getboolean('use_sonarr') and wanted_series > 0:
<div id="wanted_series" class="floating ui tiny yellow label" style="left:90% !important;top:0.5em !important;">
{% if settings.general.getboolean('use_sonarr') and wanted_series > 0 %}
<div id="wanted_series" class="floating ui tiny yellow label"
style="left:90% !important;top:0.5em !important;">
{{ wanted_series }}
</div>
% end
% if settings.general.getboolean('use_radarr') and wanted_movies > 0:
<div id="wanted_movies" class="floating ui tiny green label" style="left:90% !important;top:3em !important;">
{% endif %}
{% if settings.general.getboolean('use_radarr') and wanted_movies > 0 %}
<div id="wanted_movies" class="floating ui tiny green label"
style="left:90% !important;top:3em !important;">
{{ wanted_movies }}
</div>
% end
{% endif %}
</i>
Wanted
</a>
@ -126,11 +142,12 @@
</a>
<a class="item" href="{{ base_url }}system">
<i class="laptop icon">
% if throttled_providers_count:
<div class="floating ui tiny yellow label" style="left:90% !important;top:0.5em !important;">
{% if throttled_providers_count %}
<div class="floating ui tiny yellow label"
style="left:90% !important;top:0.5em !important;">
{{ throttled_providers_count }}
</div>
% end
{% endif %}
</i>
System
</a>
@ -159,18 +176,18 @@
<div id="dropdown_menu_button" class="ui floating right dropdown item">
<i class="inverted bars icon"></i>
<div class="ui menu">
% if settings.general.getboolean('use_sonarr'):
{% if settings.general.getboolean('use_sonarr') %}
<a class="item" href="{{ base_url }}series">
<i class="play icon"></i>
Series
</a>
% end
% if settings.general.getboolean('use_radarr'):
{% endif %}
{% if settings.general.getboolean('use_radarr') %}
<a class="item" href="{{ base_url }}movies">
<i class="film icon"></i>
Movies
</a>
% end
{% endif %}
<a class="item" href="{{ base_url }}history">
<i class="wait icon"></i>
History
@ -178,16 +195,16 @@
<a class="item" href="{{ base_url }}wanted">
<i class="warning sign icon"></i>
<span style="margin-right: 1em;">Wanted</span>
% if settings.general.getboolean('use_sonarr') and wanted_series > 0:
{% if settings.general.getboolean('use_sonarr') and wanted_series > 0 %}
<div class="ui tiny yellow label">
{{ wanted_series }}
</div>
% end
% if settings.general.getboolean('use_radarr') and wanted_movies > 0:
{% endif %}
{% if settings.general.getboolean('use_radarr') and wanted_movies > 0 %}
<div class="ui tiny green label">
{{ wanted_movies }}
</div>
% end
{% endif %}
</a>
<a class="item" href="{{ base_url }}settings">
<i class="settings icon"></i>
@ -195,11 +212,12 @@
</a>
<a class="item" href="{{ base_url }}system">
<i class="laptop icon">
% if throttled_providers_count:
<div class="floating ui tiny yellow label" style="left:90% !important;top:0.5em !important;">
{% if throttled_providers_count %}
<div class="floating ui tiny yellow label"
style="left:90% !important;top:0.5em !important;">
{{ throttled_providers_count }}
</div>
% end
{% endif %}
</i>
System
</a>
@ -214,19 +232,32 @@
</div>
</div>
% restart_required = database.execute("SELECT configured, updated FROM system")
% for item in restart_required:
% restart_required = item
% break
% end
% if restart_required['updated'] == '1' and restart_required['configured'] == '1':
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr Needs To Be Restarted To Apply The Last Update & Changes To General Settings. Click <a href=# id="restart_link">Here</a> To Restart.</div></div></div>
% elif restart_required['updated'] == '1':
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr Needs To Be Restarted To Apply Changes To The Last Update. Click <a href=# id="restart_link">Here</a> To Restart.</div></div></div>
% elif restart_required['configured'] == '1':
<div class='ui center aligned grid'><div class='fifteen wide column'><div class="ui red message">Bazarr Needs To Be Restarted To Apply Changes To General Settings. Click <a href=# id="restart_link">Here</a> To Restart.</div></div></div>
% end
{% if update_required == '1' and restart_required == '1' %}
<div class='ui center aligned grid'>
<div class='fifteen wide column'>
<div class="ui red message">Bazarr Needs To Be Restarted To Apply The Last Update & Changes To General
Settings. Click <a href=# id="restart_link">Here</a> To Restart.
</div>
</div>
</div>
{% elif updaterequired == '1' %}
<div class='ui center aligned grid'>
<div class='fifteen wide column'>
<div class="ui red message">Bazarr Needs To Be Restarted To Apply Changes To The Last Update. Click <a
href=# id="restart_link">Here</a> To Restart.
</div>
</div>
</div>
{% elif restart_required == '1' %}
<div class='ui center aligned grid'>
<div class='fifteen wide column'>
<div class="ui red message">Bazarr Needs To Be Restarted To Apply Changes To General Settings. Click <a
href=# id="restart_link">Here</a> To Restart.
</div>
</div>
</div>
{% endif %}
% from six import PY2
% import datetime
@ -237,15 +268,22 @@
<i class="python icon"></i>
<div class="content">
<div class="header">Python deprecation warning</div>
Bazarr is now compatible with Python 3.6 and newer. You should upgrade Python as we'll drop support for Python 2.7.x by the end of 2019.
Bazarr is now compatible with Python 3.6 and newer. You should upgrade Python as we'll drop support
for Python 2.7.x by the end of 2019.
<div class="ui bulleted list">
% if os.name == 'posix':
<div class="item">If you are running under Docker, don't worry, we'll take care of this for you. Just pull the new image.</div>
<div class="item">If you are running under Docker, don't worry, we'll take care of this for you.
Just pull the new image.
</div>
% end
% if os.name == 'nt':
<div class="item">If you have installed using the Windows Installer, we'll provide a new installer soon.</div>
<div class="item">If you have installed using the Windows Installer, we'll provide a new
installer soon.
</div>
% end
<div class="item">If you are running from source, it's up to you to install Python 3 and use it to run Bazarr.</div>
<div class="item">If you are running from source, it's up to you to install Python 3 and use it
to run Bazarr.
</div>
</div>
</div>
</div>
@ -285,14 +323,12 @@
$('.menu_segment').css('border-color', '#000000');
$('#divmenu').css('background', 'rgba(0, 0, 0, 0.8)');
$('#divmenu').css('box-shadow', '0 0 5px 5px #000000');
}
else if (window.location.href.indexOf("movie/") > -1) {
} else if (window.location.href.indexOf("movie/") > -1) {
$('.menu_segment').css('background', 'rgba(0, 0, 0, 0.9)');
$('.menu_segment').css('border-color', '#000000');
$('#divmenu').css('background', 'rgba(0, 0, 0, 0.8)');
$('#divmenu').css('box-shadow', '0 0 5px 5px #000000');
}
else {
} else {
$('.menu_segment').css('background', '#272727');
$('.menu_segment').css('border-color', '#272727');
$('#divmenu').css('background', '#272727');
@ -304,16 +340,18 @@
url: {{url_for('restart')}},
async: true,
error: (function () {
setTimeout(function(){ setInterval(ping, 2000); },8000);
setTimeout(function () {
setInterval(ping, 2000);
}, 8000);
})
})
});
function ping() {
$.ajax({
url: {{url_for('redirect_root')}},
url: "{{url_for('redirect_root')}}",
success: function (result) {
window.location.href= {{url_for('redirect_root')}};
window.location.href = "{{url_for('redirect_root')}}";
}
});
}
@ -336,9 +374,10 @@
var killer;
var item = {};
var length = {};
function doNotificationsAjax() {
$.ajax({
url: {{url_for('notifications')}},
url: "{{url_for('notifications')}}",
success: function (data) {
if (data !== "") {
data = JSON.parse(data);
@ -368,10 +407,14 @@
}
if (button === 'refresh') {
button = [ Noty.button('Refresh', 'ui tiny primary button', function () { window.location.reload() }) ];
button = [Noty.button('Refresh', 'ui tiny primary button', function () {
window.location.reload()
})];
} else if (button === 'restart') {
// to be completed
button = [ Noty.button('Restart', 'ui tiny primary button', function () { alert('Restart Not Implemented Yet!') }) ];
button = [Noty.button('Restart', 'ui tiny primary button', function () {
alert('Restart Not Implemented Yet!')
})];
} else {
button = [];
}
@ -416,12 +459,14 @@
}
});
}
notificationTimeout = setTimeout(doNotificationsAjax, 1000);
var tasksTimeout;
function doTasksAjax() {
$.ajax({
url: {{url_for('running_tasks_list')}},
url: "{{url_for('running_tasks_list')}}",
dataType: 'json',
success: function (data) {
$('#tasks > tbody > tr').each(function () {
@ -446,7 +491,8 @@
$('#wanted_search_missing_subtitles_movies').find('i:first').removeClass('loading');
}
%if 'no' in locals():
%
if 'no' in locals():
if ($.inArray('search_missing_subtitles_{{no}}', data['tasks']) > -1) {
$('#search_missing_subtitles').addClass('disabled');
$('#search_missing_subtitles').find('i:first').addClass('loading');
@ -462,7 +508,8 @@
$('#search_missing_subtitles_movie').removeClass('disabled');
$('#search_missing_subtitles_movie').find('i:first').removeClass('loading');
}
%end
%
end
},
complete: function (data) {
// Schedule the next
@ -470,6 +517,7 @@
}
});
}
tasksTimeout = setTimeout(doTasksAjax, 500);
$(window).bind('beforeunload', function () {

@ -78,7 +78,7 @@
</div>
</form>
</div>
{% include 'footer.tpl' %}
{% include 'footer.html' %}
</body>
</html>

@ -137,7 +137,7 @@
</div>
</form>
</div>
{% include 'footer.tpl' %}
{% include 'footer.html' %}
</body>
</html>

Loading…
Cancel
Save