You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/get_sonarr_settings.py

36 lines
1.0 KiB

7 years ago
import sqlite3
import os
import ast
def get_sonarr_settings():
# Open database connection
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
c = db.cursor()
7 years ago
# Get Sonarr API URL from database config table
c.execute('''SELECT * FROM table_settings_sonarr''')
config_sonarr = c.fetchone()
7 years ago
# Close database connection
db.close()
7 years ago
# Build Sonarr URL
ip_sonarr = config_sonarr[0]
port_sonarr = str(config_sonarr[1])
baseurl_sonarr = config_sonarr[2]
ssl_sonarr = config_sonarr[3]
apikey_sonarr = config_sonarr[4]
7 years ago
if ssl_sonarr == 1:
protocol_sonarr = "https"
else:
protocol_sonarr = "http"
if baseurl_sonarr == "/":
base_url_sonarr = ""
else:
base_url_sonarr = "/" + baseurl_sonarr.strip("/")
7 years ago
url_sonarr = protocol_sonarr + "://" + ip_sonarr + ":" + port_sonarr + base_url_sonarr
url_sonarr_short = protocol_sonarr + "://" + ip_sonarr + ":" + port_sonarr
return [url_sonarr, url_sonarr_short, apikey_sonarr]