Remove requirement to restart Bazarr when changing General setting

pull/26/head
morpheus65535 7 years ago
parent e7b261b36a
commit 0f3a483e1b

@ -288,6 +288,7 @@ def save_settings():
else: else:
settings_general_automatic = 'True' settings_general_automatic = 'True'
c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?", (settings_general_ip, settings_general_port, settings_general_baseurl, str(settings_general_pathmapping), settings_general_loglevel, settings_general_branch, settings_general_automatic)) c.execute("UPDATE table_settings_general SET ip = ?, port = ?, base_url = ?, path_mapping = ?, log_level = ?, branch=?, auto_update=?", (settings_general_ip, settings_general_port, settings_general_baseurl, str(settings_general_pathmapping), settings_general_loglevel, settings_general_branch, settings_general_automatic))
get_general_settings()
settings_sonarr_ip = request.forms.get('settings_sonarr_ip') settings_sonarr_ip = request.forms.get('settings_sonarr_ip')
settings_sonarr_port = request.forms.get('settings_sonarr_port') settings_sonarr_port = request.forms.get('settings_sonarr_port')

@ -2,29 +2,32 @@ import sqlite3
import os import os
import ast import ast
# Open database connection def get_general_settings():
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30) # Open database connection
c = db.cursor() db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
c = db.cursor()
# Get general settings from database table
c.execute("SELECT * FROM table_settings_general") # Get general settings from database table
general_settings = c.fetchone() c.execute("SELECT * FROM table_settings_general")
general_settings = c.fetchone()
# Close database connection
db.close() # Close database connection
db.close()
ip = general_settings[0]
port = general_settings[1] ip = general_settings[0]
base_url = general_settings[2] port = general_settings[1]
if base_url == (''): base_url = general_settings[2]
base_url = '/' if base_url == (''):
if general_settings[3] is None: base_url = '/'
path_mappings = [] if general_settings[3] is None:
else: path_mappings = []
path_mappings = ast.literal_eval(general_settings[3]) else:
log_level = general_settings[4] path_mappings = ast.literal_eval(general_settings[3])
branch = general_settings[5] log_level = general_settings[4]
automatic = general_settings[6] branch = general_settings[5]
automatic = general_settings[6]
return [ip, port, base_url, path_mappings, log_level, branch, automatic]
def path_replace(path): def path_replace(path):
for path_mapping in path_mappings: for path_mapping in path_mappings:
@ -47,3 +50,12 @@ def path_replace_reverse(path):
path = path.replace('\\', '/') path = path.replace('\\', '/')
break break
return path return path
result = get_general_settings()
ip = result[0]
port = result[1]
base_url = result[2]
path_mappings = result[3]
log_level = result[4]
branch = result[5]
automatic = result[6]
Loading…
Cancel
Save