From d3aa8d4c801424d83a9ceca32c6cf9516048f08c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Wed, 11 Mar 2020 06:58:45 -0400 Subject: [PATCH] WIP --- bazarr/api.py | 12 +- bazarr/config.py | 17 ++ views/_main.html | 528 +++++++++++++++++++------------------ views/episodes.html | 4 +- views/movie.html | 4 +- views/settingsgeneral.html | 450 ++++++++++++++++++------------- views/systemlogs.html | 4 +- views/systemproviders.html | 4 - views/wizard.html | 1 + 9 files changed, 577 insertions(+), 447 deletions(-) diff --git a/bazarr/api.py b/bazarr/api.py index e03e1d2ea..1ce582e61 100644 --- a/bazarr/api.py +++ b/bazarr/api.py @@ -9,9 +9,10 @@ from operator import itemgetter import platform import io from calendar import day_name +import importlib from get_args import args -from config import settings, base_url +from config import settings, base_url, save_settings from init import * import logging @@ -64,6 +65,13 @@ class Languages(Resource): return jsonify(result) +class SaveSettings(Resource): + def post(self): + save_settings(request.form.items()) + + return '', 200 + + class SystemTasks(Resource): def get(self): taskid = request.args.get('taskid') @@ -1128,6 +1136,8 @@ class SearchWantedMovies(Resource): api.add_resource(Badges, '/badges') api.add_resource(Languages, '/languages') +api.add_resource(SaveSettings, '/savesettings') + api.add_resource(SystemTasks, '/systemtasks') api.add_resource(SystemLogs, '/systemlogs') api.add_resource(SystemProviders, '/systemproviders') diff --git a/bazarr/config.py b/bazarr/config.py index 8991569bf..3aef9614b 100644 --- a/bazarr/config.py +++ b/bazarr/config.py @@ -148,6 +148,23 @@ settings.read(os.path.join(args.config_dir, 'config', 'config.ini')) base_url = settings.general.base_url +def save_settings(settings_items): + for key, value in settings_items: + settings_keys = key.split('-') + + if value == 'true': + value = 'True' + elif value == 'false': + value = 'False' + + if settings_keys[0] == 'settings': + settings[settings_keys[1]][settings_keys[2]] = str(value) + + with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle: + settings.write(handle) + + + def url_sonarr(): if settings.sonarr.getboolean('ssl'): protocol_sonarr = "https" diff --git a/views/_main.html b/views/_main.html index 847edb5b3..a28bca58e 100644 --- a/views/_main.html +++ b/views/_main.html @@ -1,9 +1,9 @@ -
-