mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-04-24 06:37:16 -04:00
Implement command line argument like requested in #85
This commit is contained in:
parent
1abfa4d0c5
commit
1c6a427b5a
23 changed files with 165 additions and 94 deletions
68
bazarr.py
68
bazarr.py
|
@ -1,13 +1,15 @@
|
|||
bazarr_version = '0.5.9'
|
||||
bazarr_version = '0.6.0'
|
||||
|
||||
import gc
|
||||
gc.enable()
|
||||
|
||||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sys
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'libs/'))
|
||||
sys.path.insert(0, os.path.join(config_dir, 'libs/'))
|
||||
|
||||
import sqlite3
|
||||
from init_db import *
|
||||
|
@ -17,7 +19,7 @@ import logging
|
|||
from logging.handlers import TimedRotatingFileHandler
|
||||
|
||||
logger = logging.getLogger('waitress')
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT log_level FROM table_settings_general")
|
||||
log_level = c.fetchone()
|
||||
|
@ -43,7 +45,7 @@ class OneLineExceptionFormatter(logging.Formatter):
|
|||
|
||||
def configure_logging():
|
||||
global fh
|
||||
fh = TimedRotatingFileHandler(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log'), when="midnight", interval=1, backupCount=7)
|
||||
fh = TimedRotatingFileHandler(os.path.join(config_dir, 'log/bazarr.log'), when="midnight", interval=1, backupCount=7)
|
||||
f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',
|
||||
'%d/%m/%Y %H:%M:%S')
|
||||
fh.setFormatter(f)
|
||||
|
@ -61,7 +63,7 @@ from update_modules import *
|
|||
|
||||
from bottle import route, run, template, static_file, request, redirect, response, HTTPError
|
||||
import bottle
|
||||
bottle.TEMPLATE_PATH.insert(0, os.path.join(os.path.dirname(__file__), 'views/'))
|
||||
bottle.TEMPLATE_PATH.insert(0, os.path.join(config_dir, 'views/'))
|
||||
bottle.debug(True)
|
||||
bottle.TEMPLATES.clear()
|
||||
|
||||
|
@ -94,7 +96,7 @@ from scheduler import *
|
|||
from notifier import send_notifications, send_notifications_movie
|
||||
|
||||
# Reset restart required warning on start
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE table_settings_general SET configured = 0, updated = 0")
|
||||
conn.commit()
|
||||
|
@ -140,7 +142,7 @@ def redirect_root():
|
|||
@route(base_url + 'static/:path#.+#', name='static')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def static(path):
|
||||
return static_file(path, root=os.path.join(os.path.dirname(__file__), 'static'))
|
||||
return static_file(path, root=os.path.join(config_dir, 'static'))
|
||||
|
||||
@route(base_url + 'emptylog')
|
||||
@custom_auth_basic(check_credentials)
|
||||
|
@ -155,7 +157,7 @@ def emptylog():
|
|||
@route(base_url + 'bazarr.log')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def download_log():
|
||||
return static_file('bazarr.log', root=os.path.join(os.path.dirname(__file__), 'data/log/'), download='bazarr.log')
|
||||
return static_file('bazarr.log', root=os.path.join(config_dir, 'log/'), download='bazarr.log')
|
||||
|
||||
@route(base_url + 'image_proxy/<url:path>', method='GET')
|
||||
@custom_auth_basic(check_credentials)
|
||||
|
@ -200,7 +202,7 @@ def image_proxy_movies(url):
|
|||
@route(base_url)
|
||||
@custom_auth_basic(check_credentials)
|
||||
def redirect_root():
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
integration = c.execute("SELECT use_sonarr, use_radarr FROM table_settings_general").fetchone()
|
||||
c.close()
|
||||
|
@ -218,7 +220,7 @@ def redirect_root():
|
|||
def series():
|
||||
single_language = get_general_settings()[7]
|
||||
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -249,7 +251,7 @@ def series():
|
|||
def serieseditor():
|
||||
single_language = get_general_settings()[7]
|
||||
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -268,7 +270,7 @@ def serieseditor():
|
|||
@route(base_url + 'search_json/<query>', method='GET')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def search_json(query):
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("SELECT title, sonarrSeriesId FROM table_shows WHERE title LIKE ? ORDER BY title", ('%'+query+'%',))
|
||||
|
@ -316,7 +318,7 @@ def edit_series(no):
|
|||
else:
|
||||
hi = "False"
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE sonarrSeriesId LIKE ?", (str(lang), hi, no))
|
||||
conn.commit()
|
||||
|
@ -336,7 +338,7 @@ def edit_serieseditor():
|
|||
lang = request.forms.getall('languages')
|
||||
hi = request.forms.get('hearing_impaired')
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
|
||||
for serie in series:
|
||||
|
@ -363,7 +365,7 @@ def episodes(no):
|
|||
# single_language = get_general_settings()[7]
|
||||
url_sonarr_short = get_sonarr_settings()[1]
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
conn.create_function("path_substitution", 1, path_replace)
|
||||
c = conn.cursor()
|
||||
|
||||
|
@ -387,7 +389,7 @@ def episodes(no):
|
|||
def movies():
|
||||
single_language = get_general_settings()[7]
|
||||
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace_movie)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -414,7 +416,7 @@ def movies():
|
|||
def movieseditor():
|
||||
single_language = get_general_settings()[7]
|
||||
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace_movie)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -440,7 +442,7 @@ def edit_movieseditor():
|
|||
lang = request.forms.getall('languages')
|
||||
hi = request.forms.get('hearing_impaired')
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
|
||||
for movie in movies:
|
||||
|
@ -482,7 +484,7 @@ def edit_movie(no):
|
|||
else:
|
||||
hi = "False"
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE table_movies SET languages = ?, hearing_impaired = ? WHERE radarrId LIKE ?", (str(lang), hi, no))
|
||||
conn.commit()
|
||||
|
@ -499,7 +501,7 @@ def movie(no):
|
|||
# single_language = get_general_settings()[7]
|
||||
url_radarr_short = get_radarr_settings()[1]
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
conn.create_function("path_substitution", 1, path_replace_movie)
|
||||
c = conn.cursor()
|
||||
|
||||
|
@ -556,7 +558,7 @@ def history():
|
|||
@route(base_url + 'historyseries')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def historyseries():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("SELECT COUNT(*) FROM table_history")
|
||||
|
@ -593,7 +595,7 @@ def historyseries():
|
|||
@route(base_url + 'historymovies')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def historymovies():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("SELECT COUNT(*) FROM table_history_movie")
|
||||
|
@ -635,7 +637,7 @@ def wanted():
|
|||
@route(base_url + 'wantedseries')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def wantedseries():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -662,7 +664,7 @@ def wantedseries():
|
|||
@route(base_url + 'wantedmovies')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def wantedmovies():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace_movie)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -698,7 +700,7 @@ def wanted_search_missing_subtitles_list():
|
|||
@route(base_url + 'settings')
|
||||
@custom_auth_basic(check_credentials)
|
||||
def settings():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_general")
|
||||
settings_general = c.fetchone()
|
||||
|
@ -722,7 +724,7 @@ def settings():
|
|||
def save_settings():
|
||||
ref = request.environ['HTTP_REFERER']
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
|
||||
settings_general_ip = request.forms.get('settings_general_ip')
|
||||
|
@ -1198,7 +1200,7 @@ def system():
|
|||
task_list.append([job.name, get_time_from_cron(job.trigger.fields), next_run, job.id])
|
||||
|
||||
i = 0
|
||||
with open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')) as f:
|
||||
with open(os.path.join(config_dir, 'log/bazarr.log')) as f:
|
||||
for i, l in enumerate(f, 1):
|
||||
pass
|
||||
row_count = i
|
||||
|
@ -1214,7 +1216,7 @@ def get_logs(page):
|
|||
begin = (page * page_size) - page_size
|
||||
end = (page * page_size) - 1
|
||||
logs_complete = []
|
||||
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
|
||||
for line in reversed(open(os.path.join(config_dir, 'log/bazarr.log')).readlines()):
|
||||
logs_complete.append(line.rstrip())
|
||||
logs = logs_complete[begin:end]
|
||||
|
||||
|
@ -1280,7 +1282,7 @@ def get_subtitle():
|
|||
sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
|
||||
# tvdbid = request.forms.get('tvdbid')
|
||||
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1")
|
||||
enabled_providers = c.fetchall()
|
||||
|
@ -1326,7 +1328,7 @@ def get_subtitle_movie():
|
|||
radarrId = request.forms.get('radarrId')
|
||||
# tmdbid = request.forms.get('tmdbid')
|
||||
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_providers WHERE enabled = 1")
|
||||
enabled_providers = c.fetchall()
|
||||
|
@ -1361,7 +1363,7 @@ def get_subtitle_movie():
|
|||
pass
|
||||
|
||||
def configured():
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE table_settings_general SET configured = 1")
|
||||
conn.commit()
|
||||
|
@ -1369,7 +1371,7 @@ def configured():
|
|||
|
||||
@route(base_url + 'api/wanted')
|
||||
def api_wanted():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
data = c.execute("SELECT table_shows.title, table_episodes.season || 'x' || table_episodes.episode, table_episodes.title, table_episodes.missing_subtitles FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.missing_subtitles != '[]' ORDER BY table_episodes._rowid_ DESC").fetchall()
|
||||
c.close()
|
||||
|
@ -1377,7 +1379,7 @@ def api_wanted():
|
|||
|
||||
@route(base_url + 'api/history')
|
||||
def api_history():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
data = c.execute("SELECT table_shows.title, table_episodes.season || 'x' || table_episodes.episode, table_episodes.title, strftime('%Y-%m-%d', datetime(table_history.timestamp, 'unixepoch')), table_history.description FROM table_history INNER JOIN table_shows on table_shows.sonarrSeriesId = table_history.sonarrSeriesId INNER JOIN table_episodes on table_episodes.sonarrEpisodeId = table_history.sonarrEpisodeId WHERE table_history.action = '1' ORDER BY id DESC").fetchall()
|
||||
c.close()
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
from get_general_settings import get_general_settings
|
||||
|
||||
import os
|
||||
|
@ -40,7 +42,7 @@ def check_and_apply_update():
|
|||
updated()
|
||||
|
||||
def updated():
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE table_settings_general SET updated = 1")
|
||||
conn.commit()
|
||||
|
|
20
get_argv.py
Normal file
20
get_argv.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import os
|
||||
import sys
|
||||
import getopt
|
||||
|
||||
config_dir = os.path.join(os.path.dirname(__file__), 'data/')
|
||||
no_update = False
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:],"h:",["no-update", "config="])
|
||||
except getopt.GetoptError:
|
||||
print 'bazarr.py -h --no-update --config <config_directory>'
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'bazarr.py -h --no-update --config <config_directory>'
|
||||
sys.exit()
|
||||
elif opt in ("--no-update"):
|
||||
no_update = True
|
||||
elif opt in ("--config"):
|
||||
config_dir = arg
|
|
@ -1,9 +1,11 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
|
||||
def get_auth_settings():
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
c.execute('''SELECT * FROM table_settings_auth''')
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import requests
|
||||
|
@ -24,7 +26,7 @@ def sync_episodes():
|
|||
apikey_sonarr = get_sonarr_settings()[2]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
import ast
|
||||
|
@ -5,7 +7,7 @@ import re
|
|||
|
||||
def get_general_settings():
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get general settings from database table
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import sqlite3
|
||||
import pycountry
|
||||
import os
|
||||
|
@ -9,7 +11,7 @@ def load_language_in_db():
|
|||
if hasattr(lang, 'alpha_2')]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Insert languages in database table
|
||||
|
@ -23,7 +25,7 @@ def load_language_in_db():
|
|||
db.close()
|
||||
|
||||
def language_from_alpha2(lang):
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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]
|
||||
|
@ -35,7 +37,7 @@ def language_from_alpha2(lang):
|
|||
def language_from_alpha3(lang):
|
||||
if lang == 'fre':
|
||||
lang = 'fra'
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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 = ?''', (lang,)).fetchone()[0]
|
||||
|
@ -47,7 +49,7 @@ def language_from_alpha3(lang):
|
|||
def alpha2_from_alpha3(lang):
|
||||
if lang == 'fre':
|
||||
lang = 'fra'
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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 = ?''', (lang,)).fetchone()[0]
|
||||
|
@ -57,7 +59,7 @@ def alpha2_from_alpha3(lang):
|
|||
return result
|
||||
|
||||
def alpha2_from_language(lang):
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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]
|
||||
|
@ -67,7 +69,7 @@ def alpha2_from_language(lang):
|
|||
return result
|
||||
|
||||
def alpha3_from_alpha2(lang):
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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]
|
||||
|
@ -77,7 +79,7 @@ def alpha3_from_alpha2(lang):
|
|||
return result
|
||||
|
||||
def alpha3_from_language(lang):
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import requests
|
||||
|
@ -16,7 +18,7 @@ def update_movies():
|
|||
movie_default_hi = get_general_settings()[20]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
if apikey_radarr == None:
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
from subliminal import provider_manager
|
||||
|
@ -6,7 +8,7 @@ from subliminal import provider_manager
|
|||
providers_list = sorted(provider_manager.names())
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Remove unsupported providers
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import sqlite3
|
||||
import os
|
||||
import ast
|
||||
|
||||
def get_radarr_settings():
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Radarr API URL from database config table
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import requests
|
||||
|
@ -15,7 +17,7 @@ def update_series():
|
|||
serie_default_hi = get_general_settings()[17]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
if apikey_sonarr == None:
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
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)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import ast
|
||||
|
@ -112,7 +114,7 @@ def series_download_subtitles(no):
|
|||
else:
|
||||
monitored_only_query_string = ""
|
||||
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes_details = c_db.execute('SELECT path, missing_subtitles, sonarrEpisodeId, scene_name FROM table_episodes WHERE sonarrSeriesId = ? AND missing_subtitles != "[]"' + monitored_only_query_string, (no,)).fetchall()
|
||||
series_details = c_db.execute("SELECT hearing_impaired FROM table_shows WHERE sonarrSeriesId = ?", (no,)).fetchone()
|
||||
|
@ -148,7 +150,7 @@ def series_download_subtitles(no):
|
|||
|
||||
|
||||
def movies_download_subtitles(no):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
movie = c_db.execute("SELECT path, missing_subtitles, radarrId, sceneName, hearing_impaired FROM table_movies WHERE radarrId = ?", (no,)).fetchone()
|
||||
enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
|
@ -182,7 +184,7 @@ def movies_download_subtitles(no):
|
|||
|
||||
|
||||
def wanted_download_subtitles(path):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes_details = c_db.execute("SELECT table_episodes.path, table_episodes.missing_subtitles, table_episodes.sonarrEpisodeId, table_episodes.sonarrSeriesId, table_shows.hearing_impaired, table_episodes.scene_name FROM table_episodes INNER JOIN table_shows on table_shows.sonarrSeriesId = table_episodes.sonarrSeriesId WHERE table_episodes.path = ? AND missing_subtitles != '[]'", (path_replace_reverse(path),)).fetchall()
|
||||
enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
|
@ -216,7 +218,7 @@ def wanted_download_subtitles(path):
|
|||
|
||||
|
||||
def wanted_download_subtitles_movie(path):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
movies_details = c_db.execute("SELECT path, missing_subtitles, radarrId, radarrId, hearing_impaired, sceneName FROM table_movies WHERE path = ? AND missing_subtitles != '[]'", (path_replace_reverse_movie(path),)).fetchall()
|
||||
enabled_providers = c_db.execute("SELECT * FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
|
@ -250,7 +252,7 @@ def wanted_download_subtitles_movie(path):
|
|||
|
||||
|
||||
def wanted_search_missing_subtitles():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
db.create_function("path_substitution_movie", 1, path_replace_movie)
|
||||
c = db.cursor()
|
||||
|
|
31
init_db.py
31
init_db.py
|
@ -1,29 +1,32 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import logging
|
||||
|
||||
# Check if config_dir exist
|
||||
if os.path.exists(config_dir) == True:
|
||||
pass
|
||||
else:
|
||||
# Create config_dir directory tree
|
||||
try:
|
||||
os.mkdir(os.path.join(config_dir))
|
||||
except OSError:
|
||||
logging.exception("The configuration directory doesn't exist and Bazarr cannot create it (permission issue?).")
|
||||
exit(2)
|
||||
|
||||
# Check if database exist
|
||||
if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) == True:
|
||||
if os.path.exists(os.path.join(config_dir, 'db/bazarr.db')) == True:
|
||||
pass
|
||||
else:
|
||||
# Create data directory tree
|
||||
try:
|
||||
os.mkdir(os.path.join(os.path.dirname(__file__), 'data'))
|
||||
os.mkdir(os.path.join(config_dir, 'db'))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
try:
|
||||
os.mkdir(os.path.join(os.path.dirname(__file__), 'data/cache'))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
try:
|
||||
os.mkdir(os.path.join(os.path.dirname(__file__), 'data/db'))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
try:
|
||||
os.mkdir(os.path.join(os.path.dirname(__file__), 'data/log'))
|
||||
os.mkdir(os.path.join(config_dir, 'log'))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
@ -35,7 +38,7 @@ else:
|
|||
fd.close()
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Execute script and commit change to database
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import gc
|
||||
import os
|
||||
import enzyme
|
||||
|
@ -59,7 +61,7 @@ def store_subtitles(file):
|
|||
if len(detected_language) > 0:
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse(os.path.join(os.path.dirname(file), subtitle))])
|
||||
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
|
||||
c_db.execute("UPDATE table_episodes SET subtitles = ? WHERE path = ?", (str(actual_subtitles), path_replace_reverse(file)))
|
||||
|
@ -111,7 +113,7 @@ def store_subtitles_movie(file):
|
|||
if len(detected_language) > 0:
|
||||
actual_subtitles.append([str(detected_language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))])
|
||||
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
|
||||
c_db.execute("UPDATE table_movies SET subtitles = ? WHERE path = ?", (str(actual_subtitles), path_replace_reverse_movie(file)))
|
||||
|
@ -128,7 +130,7 @@ def list_missing_subtitles(*no):
|
|||
query_string = " WHERE table_shows.sonarrSeriesId = " + str(no[0])
|
||||
except:
|
||||
pass
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes_subtitles = c_db.execute("SELECT table_episodes.sonarrEpisodeId, table_episodes.subtitles, table_shows.languages FROM table_episodes INNER JOIN table_shows on table_episodes.sonarrSeriesId = table_shows.sonarrSeriesId" + query_string).fetchall()
|
||||
c_db.close()
|
||||
|
@ -162,7 +164,7 @@ def list_missing_subtitles(*no):
|
|||
missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
|
||||
missing_subtitles_global.append(tuple([str(missing_subtitles), episode_subtitles[0]]))
|
||||
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
c_db.executemany("UPDATE table_episodes SET missing_subtitles = ? WHERE sonarrEpisodeId = ?", (missing_subtitles_global))
|
||||
conn_db.commit()
|
||||
|
@ -175,7 +177,7 @@ def list_missing_subtitles_movies(*no):
|
|||
query_string = " WHERE table_movies.radarrId = " + str(no[0])
|
||||
except:
|
||||
pass
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
movies_subtitles = c_db.execute("SELECT radarrId, subtitles, languages FROM table_movies" + query_string).fetchall()
|
||||
c_db.close()
|
||||
|
@ -209,14 +211,14 @@ def list_missing_subtitles_movies(*no):
|
|||
missing_subtitles = list(set(desired_subtitles) - set(actual_subtitles_list))
|
||||
missing_subtitles_global.append(tuple([str(missing_subtitles), movie_subtitles[0]]))
|
||||
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
c_db.executemany("UPDATE table_movies SET missing_subtitles = ? WHERE radarrId = ?", (missing_subtitles_global))
|
||||
conn_db.commit()
|
||||
c_db.close()
|
||||
|
||||
def series_full_scan_subtitles():
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes = c_db.execute("SELECT path FROM table_episodes").fetchall()
|
||||
c_db.close()
|
||||
|
@ -227,7 +229,7 @@ def series_full_scan_subtitles():
|
|||
gc.collect()
|
||||
|
||||
def movies_full_scan_subtitles():
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
movies = c_db.execute("SELECT path FROM table_movies").fetchall()
|
||||
c_db.close()
|
||||
|
@ -238,7 +240,7 @@ def movies_full_scan_subtitles():
|
|||
gc.collect()
|
||||
|
||||
def series_scan_subtitles(no):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes = c_db.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId = ?", (no,)).fetchall()
|
||||
c_db.close()
|
||||
|
@ -250,7 +252,7 @@ def series_scan_subtitles(no):
|
|||
|
||||
|
||||
def movies_scan_subtitles(no):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
movies = c_db.execute("SELECT path FROM table_movies WHERE radarrId = ?", (no,)).fetchall()
|
||||
c_db.close()
|
||||
|
|
10
notifier.py
10
notifier.py
|
@ -1,9 +1,11 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import apprise
|
||||
import os
|
||||
import sqlite3
|
||||
|
||||
def get_notifier_providers():
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
providers = c_db.execute('SELECT name, url FROM table_settings_notifier WHERE enabled = 1').fetchall()
|
||||
c_db.close()
|
||||
|
@ -11,7 +13,7 @@ def get_notifier_providers():
|
|||
return providers
|
||||
|
||||
def get_series_name(sonarrSeriesId):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
data = c_db.execute('SELECT title FROM table_shows WHERE sonarrSeriesId = ?', (sonarrSeriesId,)).fetchone()
|
||||
c_db.close()
|
||||
|
@ -19,7 +21,7 @@ def get_series_name(sonarrSeriesId):
|
|||
return data[0]
|
||||
|
||||
def get_episode_name(sonarrEpisodeId):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
data = c_db.execute('SELECT title FROM table_episodes WHERE sonarrEpisodeId = ?', (sonarrEpisodeId,)).fetchone()
|
||||
c_db.close()
|
||||
|
@ -27,7 +29,7 @@ def get_episode_name(sonarrEpisodeId):
|
|||
return data[0]
|
||||
|
||||
def get_movies_name(radarrId):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn_db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
data = c_db.execute('SELECT title FROM table_movies WHERE radarrId = ?', (radarrId,)).fetchone()
|
||||
c_db.close()
|
||||
|
|
11
scheduler.py
11
scheduler.py
|
@ -1,3 +1,5 @@
|
|||
from get_argv import no_update
|
||||
|
||||
from get_general_settings import automatic
|
||||
from get_sonarr_settings import get_sonarr_settings
|
||||
from get_radarr_settings import get_radarr_settings
|
||||
|
@ -44,10 +46,11 @@ if str(get_localzone()) == "local":
|
|||
else:
|
||||
scheduler = BackgroundScheduler()
|
||||
|
||||
if automatic == 'True':
|
||||
scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_bazarr', name='Update bazarr from source on Github')
|
||||
else:
|
||||
scheduler.add_job(check_and_apply_update, 'cron', year='2100', hour=4, id='update_bazarr', name='Update bazarr from source on Github')
|
||||
if no_update is False:
|
||||
if automatic == 'True':
|
||||
scheduler.add_job(check_and_apply_update, 'interval', hours=6, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_bazarr', name='Update bazarr from source on Github')
|
||||
else:
|
||||
scheduler.add_job(check_and_apply_update, 'cron', year='2100', hour=4, id='update_bazarr', name='Update bazarr from source on Github')
|
||||
|
||||
if integration[12] == "True":
|
||||
scheduler.add_job(update_series, 'interval', minutes=1, max_instances=1, coalesce=True, misfire_grace_time=15, id='update_series', name='Update series list from Sonarr')
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
|
||||
# Check if database exist
|
||||
if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) == True:
|
||||
if os.path.exists(os.path.join(config_dir, 'db/bazarr.db')) == True:
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Execute tables modifications
|
||||
|
|
6
utils.py
6
utils.py
|
@ -1,10 +1,12 @@
|
|||
from get_argv import config_dir
|
||||
|
||||
import os
|
||||
import sqlite3
|
||||
import time
|
||||
|
||||
def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
@ -19,7 +21,7 @@ def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
|
|||
|
||||
def history_log_movie(action, radarrId, description):
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
history = c.execute('''INSERT INTO table_history_movie(action, radarrId, timestamp, description) VALUES (?, ?, ?, ?)''', (action, radarrId, time.time(), description))
|
||||
|
|
|
@ -49,10 +49,11 @@
|
|||
</div>
|
||||
% include('menu.tpl')
|
||||
|
||||
% from get_argv import config_dir
|
||||
% import os
|
||||
% import sqlite3
|
||||
|
||||
% conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
% conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
% c = conn.cursor()
|
||||
|
||||
% integration = c.execute("SELECT use_sonarr, use_radarr FROM table_settings_general").fetchone()
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
% from get_argv import config_dir
|
||||
|
||||
% import os
|
||||
% import sqlite3
|
||||
% from get_general_settings import *
|
||||
|
@ -31,7 +33,7 @@
|
|||
% monitored_only_query_string = ""
|
||||
%end
|
||||
|
||||
% conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
% conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
% c = conn.cursor()
|
||||
% wanted_series = c.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string).fetchone()
|
||||
% wanted_movies = c.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string).fetchone()
|
||||
|
|
|
@ -518,6 +518,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="div_update" >
|
||||
<div class="ui dividing header">Updates</div>
|
||||
<div class="twelve wide column">
|
||||
<div class="ui grid">
|
||||
|
@ -561,6 +562,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui bottom attached tab segment" data-tab="sonarr">
|
||||
<div class="ui container"><button class="submit ui blue right floated button" type="submit" value="Submit" form="settings_form">Save</button></div>
|
||||
|
@ -1199,6 +1201,12 @@
|
|||
|
||||
|
||||
<script>
|
||||
|
||||
% from get_argv import no_update
|
||||
% if no_update is True:
|
||||
$("#div_update").hide();
|
||||
% end
|
||||
|
||||
$('.menu .item')
|
||||
.tab()
|
||||
;
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
</style>
|
||||
</head>
|
||||
<body>
|
||||
% from get_argv import config_dir
|
||||
|
||||
% import os
|
||||
% import sqlite3
|
||||
% from get_general_settings import *
|
||||
|
@ -54,7 +56,7 @@
|
|||
% monitored_only_query_string = ""
|
||||
%end
|
||||
|
||||
% conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
% conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
% c = conn.cursor()
|
||||
% wanted_series = c.execute("SELECT COUNT(*) FROM table_episodes WHERE missing_subtitles != '[]'" + monitored_only_query_string).fetchone()
|
||||
% wanted_movies = c.execute("SELECT COUNT(*) FROM table_movies WHERE missing_subtitles != '[]'" + monitored_only_query_string).fetchone()
|
||||
|
@ -68,7 +70,7 @@
|
|||
% import os
|
||||
% import sqlite3
|
||||
|
||||
% conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
% conn = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
|
||||
% c = conn.cursor()
|
||||
|
||||
% integration = c.execute("SELECT use_sonarr, use_radarr FROM table_settings_general").fetchone()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue