mirror of https://github.com/morpheus65535/bazarr
More work for new Config code
This commit is contained in:
parent
99118f87fd
commit
ead8dbfe0a
|
@ -70,7 +70,7 @@ def check_releases():
|
|||
|
||||
|
||||
def updated():
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE system SET updated = 1")
|
||||
conn.commit()
|
||||
|
|
|
@ -29,7 +29,7 @@ def sync_episodes():
|
|||
apikey_sonarr = settings.sonarr.apikey
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get current episodes id in DB
|
||||
|
@ -83,7 +83,7 @@ def sync_episodes():
|
|||
removed_episodes = list(set(current_episodes_db_list) - set(current_episodes_sonarr))
|
||||
|
||||
# Update or insert movies in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
updated_result = c.executemany('''UPDATE table_episodes SET title = ?, path = ?, season = ?, episode = ?, scene_name = ?, monitored = ? WHERE sonarrEpisodeId = ?''', episodes_to_update)
|
||||
|
|
|
@ -35,7 +35,7 @@ def load_language_in_db():
|
|||
|
||||
|
||||
def language_from_alpha2(lang):
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT name FROM table_settings_languages WHERE code2 = ?''', (lang,)).fetchone()[0]
|
||||
|
@ -48,7 +48,7 @@ def language_from_alpha2(lang):
|
|||
def language_from_alpha3(lang):
|
||||
if lang == 'fre':
|
||||
lang = 'fra'
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT name FROM table_settings_languages WHERE code3 = ? OR code3b = ?''', (lang,lang)).fetchone()[0]
|
||||
|
@ -61,7 +61,7 @@ def language_from_alpha3(lang):
|
|||
def alpha2_from_alpha3(lang):
|
||||
if lang == 'fre':
|
||||
lang = 'fra'
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT code2 FROM table_settings_languages WHERE code3 = ? OR code3b = ?''', (lang,lang)).fetchone()[0]
|
||||
|
@ -72,7 +72,7 @@ def alpha2_from_alpha3(lang):
|
|||
|
||||
|
||||
def alpha2_from_language(lang):
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT code2 FROM table_settings_languages WHERE name = ?''', (lang,)).fetchone()[0]
|
||||
|
@ -83,7 +83,7 @@ def alpha2_from_language(lang):
|
|||
|
||||
|
||||
def alpha3_from_alpha2(lang):
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT code3 FROM table_settings_languages WHERE code2 = ?''', (lang,)).fetchone()[0]
|
||||
|
@ -94,7 +94,7 @@ def alpha3_from_alpha2(lang):
|
|||
|
||||
|
||||
def alpha3_from_language(lang):
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
try:
|
||||
result = c.execute('''SELECT code3 FROM table_settings_languages WHERE name = ?''', (lang,)).fetchone()[0]
|
||||
|
|
|
@ -37,7 +37,7 @@ def update_movies():
|
|||
logging.exception("BAZARR Error trying to get movies from Radarr.")
|
||||
else:
|
||||
# Get current movies in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
current_movies_db = c.execute('SELECT tmdbId FROM table_movies').fetchall()
|
||||
db.close()
|
||||
|
@ -90,7 +90,7 @@ def update_movies():
|
|||
logging.error('BAZARR Radarr returned a movie without a file path: ' + movie["path"] + separator + movie['movieFile']['relativePath'])
|
||||
|
||||
# Update or insert movies in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
updated_result = c.executemany('''UPDATE table_movies SET title = ?, path = ?, tmdbId = ?, radarrId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ?, sceneName = ?, monitored = ?, sortTitle= ? WHERE tmdbid = ?''', movies_to_update)
|
||||
|
@ -106,7 +106,7 @@ def update_movies():
|
|||
|
||||
removed_movies = list(set(current_movies_db_list) - set(current_movies_radarr))
|
||||
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
for removed_movie in removed_movies:
|
||||
c.execute('DELETE FROM table_movies WHERE tmdbId = ?', (removed_movie,))
|
||||
|
|
|
@ -35,7 +35,7 @@ def update_series():
|
|||
logging.exception("BAZARR Error trying to get series from Sonarr.")
|
||||
else:
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get current shows in DB
|
||||
|
@ -76,7 +76,7 @@ def update_series():
|
|||
series_to_add.append((show["title"], show["path"], show["tvdbId"], show["tvdbId"], show["tvdbId"], show["id"], overview, poster, fanart, profile_id_to_language(show['qualityProfileId']), show['sortTitle']))
|
||||
|
||||
# Update or insert series in DB
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
updated_result = c.executemany('''UPDATE table_shows SET title = ?, path = ?, tvdbId = ?, sonarrSeriesId = ?, overview = ?, poster = ?, fanart = ?, `audio_language` = ? , sortTitle = ? WHERE tvdbid = ?''', series_to_update)
|
||||
|
@ -98,7 +98,7 @@ def update_series():
|
|||
for item in current_shows_db_list:
|
||||
if item not in current_shows_sonarr:
|
||||
deleted_items.append(tuple([item]))
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.executemany('DELETE FROM table_shows WHERE tvdbId = ?',deleted_items)
|
||||
db.commit()
|
||||
|
|
|
@ -1,473 +0,0 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
import ast
|
||||
from configparser import ConfigParser
|
||||
|
||||
config_file = os.path.normpath(os.path.join(config_dir, 'config/config.ini'))
|
||||
|
||||
def get_general_settings():
|
||||
cfg = ConfigParser()
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
cfg.read_file(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if cfg.has_section('general'):
|
||||
if cfg.has_option('general', 'ip'):
|
||||
ip = cfg.get('general', 'ip')
|
||||
else:
|
||||
ip = '0.0.0.0'
|
||||
|
||||
if cfg.has_option('general', 'port'):
|
||||
port = cfg.get('general', 'port')
|
||||
else:
|
||||
port = '6767'
|
||||
|
||||
if cfg.has_option('general', 'base_url'):
|
||||
base_url = cfg.get('general', 'base_url')
|
||||
if base_url.endswith('/') is False:
|
||||
base_url += '/'
|
||||
else:
|
||||
base_url = '/'
|
||||
|
||||
if cfg.has_option('general', 'path_mappings'):
|
||||
path_mappings = cfg.get('general', 'path_mappings')
|
||||
else:
|
||||
path_mappings = '[]'
|
||||
|
||||
if cfg.has_option('general', 'debug'):
|
||||
debug = cfg.getboolean('general', 'debug')
|
||||
else:
|
||||
debug = False
|
||||
|
||||
if cfg.has_option('general', 'branch'):
|
||||
branch = cfg.get('general', 'branch')
|
||||
else:
|
||||
branch = 'master'
|
||||
|
||||
if cfg.has_option('general', 'auto_update'):
|
||||
auto_update = cfg.getboolean('general', 'auto_update')
|
||||
else:
|
||||
auto_update = True
|
||||
|
||||
if cfg.has_option('general', 'single_language'):
|
||||
single_language = cfg.getboolean('general', 'single_language')
|
||||
else:
|
||||
single_language = False
|
||||
|
||||
if cfg.has_option('general', 'minimum_score'):
|
||||
minimum_score = cfg.get('general', 'minimum_score')
|
||||
else:
|
||||
minimum_score = '90'
|
||||
|
||||
if cfg.has_option('general', 'use_scenename'):
|
||||
use_scenename = cfg.getboolean('general', 'use_scenename')
|
||||
else:
|
||||
use_scenename = True
|
||||
|
||||
if cfg.has_option('general', 'use_postprocessing'):
|
||||
use_postprocessing = cfg.getboolean('general', 'use_postprocessing')
|
||||
else:
|
||||
use_postprocessing = False
|
||||
|
||||
if cfg.has_option('general', 'postprocessing_cmd'):
|
||||
postprocessing_cmd = cfg.get('general', 'postprocessing_cmd')
|
||||
else:
|
||||
postprocessing_cmd = ''
|
||||
|
||||
if cfg.has_option('general', 'use_sonarr'):
|
||||
use_sonarr = cfg.getboolean('general', 'use_sonarr')
|
||||
else:
|
||||
use_sonarr = False
|
||||
|
||||
if cfg.has_option('general', 'use_radarr'):
|
||||
use_radarr = cfg.getboolean('general', 'use_radarr')
|
||||
else:
|
||||
use_radarr = False
|
||||
|
||||
if cfg.has_option('general', 'path_mappings_movie'):
|
||||
path_mappings_movie = cfg.get('general', 'path_mappings_movie')
|
||||
else:
|
||||
path_mappings_movie = '[]'
|
||||
|
||||
if cfg.has_option('general', 'serie_default_enabled'):
|
||||
serie_default_enabled = cfg.getboolean('general', 'serie_default_enabled')
|
||||
else:
|
||||
serie_default_enabled = False
|
||||
|
||||
if cfg.has_option('general', 'serie_default_language'):
|
||||
serie_default_language = cfg.get('general', 'serie_default_language')
|
||||
else:
|
||||
serie_default_language = []
|
||||
|
||||
if cfg.has_option('general', 'serie_default_hi'):
|
||||
serie_default_hi = cfg.get('general', 'serie_default_hi')
|
||||
else:
|
||||
serie_default_hi = 'False'
|
||||
|
||||
if cfg.has_option('general', 'movie_default_enabled'):
|
||||
movie_default_enabled = cfg.getboolean('general', 'movie_default_enabled')
|
||||
else:
|
||||
movie_default_enabled = False
|
||||
|
||||
if cfg.has_option('general', 'movie_default_language'):
|
||||
movie_default_language = cfg.get('general', 'movie_default_language')
|
||||
else:
|
||||
movie_default_language = []
|
||||
|
||||
if cfg.has_option('general', 'movie_default_hi'):
|
||||
movie_default_hi = cfg.get('general', 'movie_default_hi')
|
||||
else:
|
||||
movie_default_hi = 'False'
|
||||
|
||||
if cfg.has_option('general', 'page_size'):
|
||||
page_size = cfg.get('general', 'page_size')
|
||||
else:
|
||||
page_size = '25'
|
||||
|
||||
if cfg.has_option('general', 'minimum_score_movie'):
|
||||
minimum_score_movie = cfg.get('general', 'minimum_score_movie')
|
||||
else:
|
||||
minimum_score_movie = '70'
|
||||
|
||||
if cfg.has_option('general', 'use_embedded_subs'):
|
||||
use_embedded_subs = cfg.getboolean('general', 'use_embedded_subs')
|
||||
else:
|
||||
use_embedded_subs = True
|
||||
|
||||
if cfg.has_option('general', 'only_monitored'):
|
||||
only_monitored = cfg.getboolean('general', 'only_monitored')
|
||||
else:
|
||||
only_monitored = False
|
||||
|
||||
if cfg.has_option('general', 'adaptive_searching'):
|
||||
adaptive_searching = cfg.getboolean('general', 'adaptive_searching')
|
||||
else:
|
||||
adaptive_searching = False
|
||||
|
||||
else:
|
||||
ip = '0.0.0.0'
|
||||
port = '6767'
|
||||
base_url = '/'
|
||||
path_mappings = '[]'
|
||||
debug = False
|
||||
branch = 'master'
|
||||
auto_update = True
|
||||
single_language = False
|
||||
minimum_score = '90'
|
||||
use_scenename = True
|
||||
use_postprocessing = False
|
||||
postprocessing_cmd = ''
|
||||
use_sonarr = False
|
||||
use_radarr = False
|
||||
path_mappings_movie = '[]'
|
||||
serie_default_enabled = False
|
||||
serie_default_language = []
|
||||
serie_default_hi = 'False'
|
||||
movie_default_enabled = False
|
||||
movie_default_language = []
|
||||
movie_default_hi = 'False'
|
||||
page_size = '25'
|
||||
minimum_score_movie = '70'
|
||||
use_embedded_subs = True
|
||||
only_monitored = False
|
||||
adaptive_searching = False
|
||||
|
||||
return [ip, port, base_url, path_mappings, debug, branch, auto_update, single_language, minimum_score, use_scenename, use_postprocessing, postprocessing_cmd, use_sonarr, use_radarr, path_mappings_movie, serie_default_enabled, serie_default_language, serie_default_hi, movie_default_enabled,movie_default_language, movie_default_hi, page_size, minimum_score_movie, use_embedded_subs, only_monitored, adaptive_searching]
|
||||
|
||||
|
||||
def get_auth_settings():
|
||||
cfg = ConfigParser()
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
cfg.read_file(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if cfg.has_section('auth'):
|
||||
if cfg.has_option('auth', 'type'):
|
||||
type = cfg.get('auth', 'type')
|
||||
else:
|
||||
type = None
|
||||
|
||||
if cfg.has_option('auth', 'username'):
|
||||
username = cfg.get('auth', 'username')
|
||||
else:
|
||||
username = ''
|
||||
|
||||
if cfg.has_option('auth', 'password'):
|
||||
password = cfg.get('auth', 'password')
|
||||
else:
|
||||
password = ''
|
||||
else:
|
||||
type = None
|
||||
username = ''
|
||||
password = ''
|
||||
|
||||
return [type, username, password]
|
||||
|
||||
|
||||
def get_proxy_settings():
|
||||
cfg = ConfigParser()
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
cfg.read_file(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if cfg.has_section('proxy'):
|
||||
if cfg.has_option('proxy', 'type'):
|
||||
proxy_type = cfg.get('proxy', 'type')
|
||||
else:
|
||||
proxy_type = 'None'
|
||||
|
||||
if cfg.has_option('proxy', 'url'):
|
||||
url = cfg.get('proxy', 'url')
|
||||
else:
|
||||
url = ''
|
||||
|
||||
if cfg.has_option('proxy', 'port'):
|
||||
port = cfg.get('proxy', 'port')
|
||||
else:
|
||||
port = ''
|
||||
|
||||
if cfg.has_option('proxy', 'username'):
|
||||
username = cfg.get('proxy', 'username')
|
||||
else:
|
||||
username = ''
|
||||
|
||||
if cfg.has_option('proxy', 'password'):
|
||||
password = cfg.get('proxy', 'password')
|
||||
else:
|
||||
password = ''
|
||||
|
||||
if cfg.has_option('proxy', 'exclude'):
|
||||
exclude = cfg.get('proxy', 'exclude')
|
||||
else:
|
||||
exclude = 'localhost,127.0.0.1'
|
||||
else:
|
||||
proxy_type = 'None'
|
||||
url = ''
|
||||
port = ''
|
||||
username = ''
|
||||
password = ''
|
||||
exclude = 'localhost,127.0.0.1'
|
||||
|
||||
return [proxy_type, url, port, username, password, exclude]
|
||||
|
||||
|
||||
def get_sonarr_settings():
|
||||
cfg = ConfigParser()
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
cfg.read_file(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if cfg.has_section('sonarr'):
|
||||
if cfg.has_option('sonarr', 'ip'):
|
||||
ip = cfg.get('sonarr', 'ip')
|
||||
else:
|
||||
ip = '127.0.0.1'
|
||||
|
||||
if cfg.has_option('sonarr', 'port'):
|
||||
port = cfg.get('sonarr', 'port')
|
||||
else:
|
||||
port = '8989'
|
||||
|
||||
if cfg.has_option('sonarr', 'base_url'):
|
||||
base_url = cfg.get('sonarr', 'base_url')
|
||||
else:
|
||||
base_url = '/'
|
||||
|
||||
if cfg.has_option('sonarr', 'ssl'):
|
||||
ssl = cfg.getboolean('sonarr', 'ssl')
|
||||
else:
|
||||
ssl = False
|
||||
|
||||
if cfg.has_option('sonarr', 'apikey'):
|
||||
apikey = cfg.get('sonarr', 'apikey')
|
||||
else:
|
||||
apikey = ''
|
||||
|
||||
if cfg.has_option('sonarr', 'full_update'):
|
||||
full_update = cfg.get('sonarr', 'full_update')
|
||||
else:
|
||||
full_update = 'Dayly'
|
||||
else:
|
||||
ip = '127.0.0.1'
|
||||
port = '8989'
|
||||
base_url = '/'
|
||||
ssl = False
|
||||
apikey = ''
|
||||
full_update = 'Daily'
|
||||
|
||||
if ssl == 1:
|
||||
protocol_sonarr = "https"
|
||||
else:
|
||||
protocol_sonarr = "http"
|
||||
|
||||
if base_url == None:
|
||||
base_url = "/"
|
||||
if base_url.startswith("/") == False:
|
||||
base_url = "/" + base_url
|
||||
if base_url.endswith("/"):
|
||||
base_url = base_url[:-1]
|
||||
|
||||
url_sonarr = protocol_sonarr + "://" + ip + ":" + port + base_url
|
||||
url_sonarr_short = protocol_sonarr + "://" + ip + ":" + port
|
||||
|
||||
|
||||
|
||||
return [ip, port, base_url, ssl, apikey, full_update, url_sonarr, url_sonarr_short]
|
||||
|
||||
|
||||
def get_radarr_settings():
|
||||
cfg = ConfigParser()
|
||||
try:
|
||||
with open(config_file, 'r') as f:
|
||||
cfg.read_file(f)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if cfg.has_section('radarr'):
|
||||
if cfg.has_option('radarr', 'ip'):
|
||||
ip = cfg.get('radarr', 'ip')
|
||||
else:
|
||||
ip = '127.0.0.1'
|
||||
|
||||
if cfg.has_option('radarr', 'port'):
|
||||
port = cfg.get('radarr', 'port')
|
||||
else:
|
||||
port = '7878'
|
||||
|
||||
if cfg.has_option('radarr', 'base_url'):
|
||||
base_url = cfg.get('radarr', 'base_url')
|
||||
else:
|
||||
base_url = '/'
|
||||
|
||||
if cfg.has_option('radarr', 'ssl'):
|
||||
ssl = cfg.getboolean('radarr', 'ssl')
|
||||
else:
|
||||
ssl = False
|
||||
|
||||
if cfg.has_option('radarr', 'apikey'):
|
||||
apikey = cfg.get('radarr', 'apikey')
|
||||
else:
|
||||
apikey = ''
|
||||
|
||||
if cfg.has_option('radarr', 'full_update'):
|
||||
full_update = cfg.get('radarr', 'full_update')
|
||||
else:
|
||||
full_update = 'Dayly'
|
||||
else:
|
||||
ip = '127.0.0.1'
|
||||
port = '7878'
|
||||
base_url = '/'
|
||||
ssl = False
|
||||
apikey = ''
|
||||
full_update = 'Daily'
|
||||
|
||||
if ssl == 1:
|
||||
protocol_radarr = "https"
|
||||
else:
|
||||
protocol_radarr = "http"
|
||||
|
||||
if base_url is None:
|
||||
base_url = "/"
|
||||
if base_url.startswith("/") is False:
|
||||
base_url = "/" + base_url
|
||||
if base_url.endswith("/"):
|
||||
base_url = base_url[:-1]
|
||||
|
||||
url_radarr = protocol_radarr + "://" + ip + ":" + port + base_url
|
||||
url_radarr_short = protocol_radarr + "://" + ip + ":" + port
|
||||
|
||||
return [ip, port, base_url, ssl, apikey, full_update, url_radarr , url_radarr_short]
|
||||
|
||||
|
||||
def path_replace(path):
|
||||
for path_mapping in path_mappings:
|
||||
if path_mapping[0] in path:
|
||||
path = path.replace(path_mapping[0], path_mapping[1])
|
||||
if path.startswith('\\\\') or re.match(r'^[a-zA-Z]:\\', path):
|
||||
path = path.replace('/', '\\')
|
||||
elif path.startswith('/'):
|
||||
path = path.replace('\\', '/')
|
||||
break
|
||||
return path
|
||||
|
||||
def path_replace_reverse(path):
|
||||
for path_mapping in path_mappings:
|
||||
if path_mapping[1] in path:
|
||||
path = path.replace(path_mapping[1], path_mapping[0])
|
||||
if path.startswith('\\\\') or re.match(r'^[a-zA-Z]:\\', path):
|
||||
path = path.replace('/', '\\')
|
||||
elif path.startswith('/'):
|
||||
path = path.replace('\\', '/')
|
||||
break
|
||||
return path
|
||||
|
||||
def path_replace_movie(path):
|
||||
for path_mapping in path_mappings_movie:
|
||||
if path_mapping[0] in path:
|
||||
path = path.replace(path_mapping[0], path_mapping[1])
|
||||
if path.startswith('\\\\') or re.match(r'^[a-zA-Z]:\\', path):
|
||||
path = path.replace('/', '\\')
|
||||
elif path.startswith('/'):
|
||||
path = path.replace('\\', '/')
|
||||
break
|
||||
return path
|
||||
|
||||
def path_replace_reverse_movie(path):
|
||||
for path_mapping in path_mappings_movie:
|
||||
if path_mapping[1] in path:
|
||||
path = path.replace(path_mapping[1], path_mapping[0])
|
||||
if path.startswith('\\\\') or re.match(r'^[a-zA-Z]:\\', path):
|
||||
path = path.replace('/', '\\')
|
||||
elif path.startswith('/'):
|
||||
path = path.replace('\\', '/')
|
||||
break
|
||||
return path
|
||||
|
||||
def pp_replace(pp_command, episode, subtitles, language, language_code2, language_code3):
|
||||
pp_command = pp_command.replace('{{directory}}', os.path.dirname(episode))
|
||||
pp_command = pp_command.replace('{{episode}}', episode)
|
||||
pp_command = pp_command.replace('{{episode_name}}', os.path.splitext(os.path.basename(episode))[0])
|
||||
pp_command = pp_command.replace('{{subtitles}}', subtitles)
|
||||
pp_command = pp_command.replace('{{subtitles_language}}', language)
|
||||
pp_command = pp_command.replace('{{subtitles_language_code2}}', language_code2)
|
||||
pp_command = pp_command.replace('{{subtitles_language_code3}}', language_code3)
|
||||
return pp_command
|
||||
|
||||
result = get_general_settings()
|
||||
ip = result[0]
|
||||
port = result[1]
|
||||
base_url = result[2]
|
||||
path_mappings = ast.literal_eval(result[3])
|
||||
debug = result[4]
|
||||
branch = result[5]
|
||||
automatic = result[6]
|
||||
single_language = result[7]
|
||||
minimum_score = result[8]
|
||||
use_scenename = result[9]
|
||||
use_processing = result[10]
|
||||
postprocessing_cmd = result[11]
|
||||
use_sonarr = result[12]
|
||||
use_radarr = result[13]
|
||||
path_mappings_movie = ast.literal_eval(result[14])
|
||||
serie_default_enabled = result[15]
|
||||
serie_default_language = result[16]
|
||||
serie_default_hi = result[17]
|
||||
movie_default_enabled = result[18]
|
||||
movie_default_language = result[19]
|
||||
movie_default_hi = result[20]
|
||||
page_size = result[21]
|
||||
minimum_score_movie = result[22]
|
||||
use_embedded_subs = result[23]
|
||||
only_monitored = result[24]
|
||||
adaptive_searching = result[25]
|
|
@ -76,7 +76,7 @@ def store_subtitles(file):
|
|||
logging.debug("BAZARR external subtitles detected and analysis guessed this language: " + str(detected_language))
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))])
|
||||
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db', 'bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
logging.debug("BAZARR storing those languages to DB: " + str(actual_subtitles))
|
||||
c_db.execute("UPDATE table_episodes SET subtitles = ? WHERE path = ?", (str(actual_subtitles), path_replace_reverse(file)))
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
<body>
|
||||
%import ast
|
||||
%from get_languages import *
|
||||
%from get_settings import *
|
||||
%single_language = get_general_settings()[7]
|
||||
<div style="display: none;"><img src="{{base_url}}image_proxy{{details[3]}}"></div>
|
||||
<div id='loader' class="ui page dimmer">
|
||||
|
|
Loading…
Reference in New Issue