mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-24 00:33:27 +00:00
Remove requirement to restart Bazarr when changing General setting
This commit is contained in:
parent
e7b261b36a
commit
0f3a483e1b
2 changed files with 33 additions and 20 deletions
|
@ -288,6 +288,7 @@ def save_settings():
|
|||
else:
|
||||
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))
|
||||
get_general_settings()
|
||||
|
||||
settings_sonarr_ip = request.forms.get('settings_sonarr_ip')
|
||||
settings_sonarr_port = request.forms.get('settings_sonarr_port')
|
||||
|
|
|
@ -2,29 +2,32 @@ import sqlite3
|
|||
import os
|
||||
import ast
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
def get_general_settings():
|
||||
# Open database connection
|
||||
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")
|
||||
general_settings = c.fetchone()
|
||||
# Get general settings from database table
|
||||
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]
|
||||
base_url = general_settings[2]
|
||||
if base_url == (''):
|
||||
base_url = '/'
|
||||
if general_settings[3] is None:
|
||||
path_mappings = []
|
||||
else:
|
||||
path_mappings = ast.literal_eval(general_settings[3])
|
||||
log_level = general_settings[4]
|
||||
branch = general_settings[5]
|
||||
automatic = general_settings[6]
|
||||
ip = general_settings[0]
|
||||
port = general_settings[1]
|
||||
base_url = general_settings[2]
|
||||
if base_url == (''):
|
||||
base_url = '/'
|
||||
if general_settings[3] is None:
|
||||
path_mappings = []
|
||||
else:
|
||||
path_mappings = ast.literal_eval(general_settings[3])
|
||||
log_level = general_settings[4]
|
||||
branch = general_settings[5]
|
||||
automatic = general_settings[6]
|
||||
|
||||
return [ip, port, base_url, path_mappings, log_level, branch, automatic]
|
||||
|
||||
def path_replace(path):
|
||||
for path_mapping in path_mappings:
|
||||
|
@ -47,3 +50,12 @@ def path_replace_reverse(path):
|
|||
path = path.replace('\\', '/')
|
||||
break
|
||||
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…
Reference in a new issue