1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-25 01:02:19 +00:00
This commit is contained in:
Louis Vézina 2020-02-16 19:38:10 -05:00
parent 710db7e94f
commit 630f7e8394
5 changed files with 218 additions and 29 deletions

View file

@ -6,7 +6,10 @@ import datetime
import pretty import pretty
import time import time
from operator import itemgetter from operator import itemgetter
import platform
import io
from get_args import args
from config import settings, base_url from config import settings, base_url
from init import * from init import *
@ -21,7 +24,7 @@ from get_subtitle import download_subtitle, series_download_subtitles, movies_do
from notifier import send_notifications, send_notifications_movie from notifier import send_notifications, send_notifications_movie
from list_subtitles import store_subtitles, store_subtitles_movie, series_scan_subtitles, movies_scan_subtitles, \ from list_subtitles import store_subtitles, store_subtitles_movie, series_scan_subtitles, movies_scan_subtitles, \
list_missing_subtitles, list_missing_subtitles_movies list_missing_subtitles, list_missing_subtitles_movies
from utils import history_log, history_log_movie from utils import history_log, history_log_movie, get_sonarr_version, get_radarr_version
from get_providers import get_providers, get_providers_auth, list_throttled_providers from get_providers import get_providers, get_providers_auth, list_throttled_providers
from websocket_handler import event_stream from websocket_handler import event_stream
@ -57,6 +60,37 @@ class Languages(Resource):
return jsonify(result) return jsonify(result)
class SystemStatus(Resource):
def get(self):
system_status = {}
system_status.update({'bazarr_version': os.environ["BAZARR_VERSION"]})
system_status.update({'sonarr_version': get_sonarr_version()})
system_status.update({'radarr_version': get_radarr_version()})
system_status.update({'operating_system': platform.platform()})
system_status.update({'python_version': platform.python_version()})
system_status.update({'bazarr_directory': os.path.dirname(os.path.dirname(__file__))})
system_status.update({'bazarr_config_directory': args.config_dir})
return jsonify(data=system_status)
class SystemReleases(Resource):
def get(self):
releases = []
try:
with io.open(os.path.join(args.config_dir, 'config', 'releases.txt'), 'r', encoding='UTF-8') as f:
releases = ast.literal_eval(f.read())
for release in releases:
release[1] = release[1].replace('- ', '')
release[1] = release[1].split('\r\n')
release[1].pop(0)
release.append(True if release[0].lstrip('v') == os.environ["BAZARR_VERSION"] else False)
except Exception as e:
logging.exception(
'BAZARR cannot parse releases caching file: ' + os.path.join(args.config_dir, 'config', 'releases.txt'))
return jsonify(data=releases)
class Series(Resource): class Series(Resource):
def get(self): def get(self):
start = request.args.get('start') or 0 start = request.args.get('start') or 0
@ -1044,6 +1078,9 @@ class SearchWantedMovies(Resource):
api.add_resource(Badges, '/badges') api.add_resource(Badges, '/badges')
api.add_resource(Languages, '/languages') api.add_resource(Languages, '/languages')
api.add_resource(SystemStatus, '/systemstatus')
api.add_resource(SystemReleases, '/systemreleases')
api.add_resource(Series, '/series') api.add_resource(Series, '/series')
api.add_resource(SeriesEditSave, '/series_edit_save') api.add_resource(SeriesEditSave, '/series_edit_save')
api.add_resource(Episodes, '/episodes') api.add_resource(Episodes, '/episodes')

View file

@ -1016,35 +1016,16 @@ def check_update():
redirect(ref) redirect(ref)
@app.route('/system') @app.route('/systemstatus')
@login_required @login_required
def system(): def systemstatus():
return render_template('systemstatus.html')
task_list = scheduler.get_task_list() @app.route('/systemreleases')
@login_required
throttled_providers = list_throttled_providers() def systemreleases():
return render_template('systemreleases.html')
try:
with io.open(os.path.join(args.config_dir, 'config', 'releases.txt'), 'r', encoding='UTF-8') as f:
releases = ast.literal_eval(f.read())
except Exception as e:
releases = []
logging.exception(
'BAZARR cannot parse releases caching file: ' + os.path.join(args.config_dir, 'config', 'releases.txt'))
sonarr_version = get_sonarr_version()
radarr_version = get_radarr_version()
page_size = int(settings.general.page_size)
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__))),
base_url=base_url, task_list=task_list, page_size=page_size, releases=releases,
current_port=settings.general.port, throttled_providers=throttled_providers)
@app.route('/logs') @app.route('/logs')

View file

@ -191,8 +191,8 @@
<li><a href="/"> Tasks</a></li> <li><a href="/"> Tasks</a></li>
<li><a href="/"> Logs</a></li> <li><a href="/"> Logs</a></li>
<li><a href="/"> Providers</a></li> <li><a href="/"> Providers</a></li>
<li><a href="/"> Status</a></li> <li><a href="{{ url_for('systemstatus') }}"> Status</a></li>
<li><a href="/"> Releases</a></li> <li><a href="{{ url_for('systemreleases') }}"> Releases</a></li>
</ul> </ul>
</li> </li>
</ul> </ul>

42
views/systemreleases.html Normal file
View file

@ -0,0 +1,42 @@
{% extends '_main.html' %}
{% block title %}Releases - Bazarr{% endblock %}
{% block bcleft %}
{% endblock bcleft %}
{% block bcright %}
{% endblock bcright %}
{% block body %}
<div class="container-fluid">
<span id="releases"></span>
</div>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
$.ajax({
url: "{{ url_for('api.systemreleases') }}"
}).done(function (data) {
var releases = '';
data.data.forEach(appendFunc);
function appendFunc(value) {
entries = '';
value[1].forEach(appendEntry);
releases = releases + '<h4>'+value[0]+((value[2]) ? ' <span class="badge badge-success">Current Version</span>' : '')+'</h4><hr/><p><b>From newest to oldest:</b></p><ul>'+entries+'</ul>';
function appendEntry(entry) {
entries = entries + '<li>'+entry+'</li>';
}
}
$('#releases').html(releases);
});
})
</script>
{% endblock tail %}

129
views/systemstatus.html Normal file
View file

@ -0,0 +1,129 @@
{% extends '_main.html' %}
{% block title %}Status - Bazarr{% endblock %}
{% block bcleft %}
{% endblock bcleft %}
{% block bcright %}
{% endblock bcright %}
{% block body %}
<div class="container-fluid">
<h2>About</h2><hr/>
<div class="row">
<div class="col-sm-2 text-right">
<b>Bazarr Version:</b>
</div>
<div class="col-sm-8">
<span id="bazarr_version_span"></span>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Sonarr Version:</b>
</div>
<div class="col-sm-8">
<span id="sonarr_version_span"></span>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Radarr Version:</b>
</div>
<div class="col-sm-8">
<span id="radarr_version_span"></span>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Operating System:</b>
</div>
<div class="col-sm-8">
<span id="operating_system_span"></span>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Python Version:</b>
</div>
<div class="col-sm-8">
<span id="python_version_span"></span>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Bazarr Directory:</b>
</div>
<div class="col-sm-8">
<span id="bazarr_directory_span"></span>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Bazarr Config Directory:</b>
</div>
<div class="col-sm-8">
<span id="bazarr_config_directory_span"></span>
</div>
</div>
<br>
<h2>More info</h2><hr/>
<div class="row">
<div class="col-sm-2 text-right">
<b>Home Page:</b>
</div>
<div class="col-sm-8">
<i class="fas fa-paper-plane"></i>
<a href="https://www.bazarr.media" target="_blank">Bazarr Website</a>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Source:</b>
</div>
<div class="col-sm-8">
<i class="fab fa-github"></i>
<a href="https://github.com/morpheus65535/bazarr" target="_blank">Bazarr on GitHub</a>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Wiki:</b>
</div>
<div class="col-sm-8">
<i class="fab fa-wikipedia-w"></i>
<a href="https://github.com/morpheus65535/bazarr/wiki" target="_blank">Bazarr Wiki</a>
</div>
</div>
<div class="row">
<div class="col-sm-2 text-right">
<b>Discord:</b>
</div>
<div class="col-sm-8">
<i class="fab fa-discord"></i>
<a href="https://discord.gg/MH2e2eb" target="_blank">Bazarr on Discord</a>
</div>
</div>
</div>
{% endblock body %}
{% block tail %}
<script>
$(document).ready(function () {
$.ajax({
url: "{{ url_for('api.systemstatus') }}"
}).done(function (data) {
$('#bazarr_version_span').text(data.data['bazarr_version']);
$('#sonarr_version_span').text(data.data['sonarr_version']);
$('#radarr_version_span').text(data.data['radarr_version']);
$('#operating_system_span').text(data.data['operating_system']);
$('#python_version_span').text(data.data['python_version']);
$('#bazarr_directory_span').text(data.data['bazarr_directory']);
$('#bazarr_config_directory_span').text(data.data['bazarr_config_directory']);
});
})
</script>
{% endblock tail %}