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 @@ -
-