mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-28 09:37:55 +08:00
Increase SQlite timeout to 30 seconds
This commit is contained in:
parent
6aa561c0c3
commit
679813efa4
12 changed files with 54 additions and 28 deletions
21
bazarr.py
21
bazarr.py
|
@ -21,6 +21,7 @@ from fdsend import send_file
|
|||
import urllib
|
||||
|
||||
from init_db import *
|
||||
from update_db import *
|
||||
from get_languages import *
|
||||
from get_providers import *
|
||||
|
||||
|
@ -38,7 +39,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'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT log_level FROM table_settings_general")
|
||||
log_level = c.fetchone()
|
||||
|
@ -68,7 +69,7 @@ def configure_logging():
|
|||
f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',
|
||||
'%d/%m/%Y %H:%M:%S')
|
||||
fh.setFormatter(f)
|
||||
logging.getLogger("enzyme").setLevel(logging.ERROR)
|
||||
logging.getLogger("enzyme").setLevel(logging.CRITICAL)
|
||||
logging.getLogger("apscheduler").setLevel(logging.WARNING)
|
||||
logging.getLogger("subliminal").setLevel(logging.ERROR)
|
||||
root = logging.getLogger()
|
||||
|
@ -96,7 +97,7 @@ def image_proxy(url):
|
|||
|
||||
@route(base_url)
|
||||
def series():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT tvdbId, title, path_substitution(path), languages, hearing_impaired, sonarrSeriesId, poster FROM table_shows ORDER BY title")
|
||||
|
@ -126,7 +127,7 @@ def edit_series(no):
|
|||
else:
|
||||
hi = "False"
|
||||
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE tvdbId LIKE ?", (str(lang), hi, no))
|
||||
conn.commit()
|
||||
|
@ -138,7 +139,7 @@ def edit_series(no):
|
|||
|
||||
@route(base_url + 'episodes/<no:int>', method='GET')
|
||||
def episodes(no):
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
conn.create_function("path_substitution", 1, path_replace)
|
||||
c = conn.cursor()
|
||||
|
||||
|
@ -173,7 +174,7 @@ def search_missing_subtitles(no):
|
|||
|
||||
@route(base_url + 'history')
|
||||
def history():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("SELECT COUNT(*) FROM table_history")
|
||||
|
@ -193,7 +194,7 @@ def history():
|
|||
|
||||
@route(base_url + 'wanted')
|
||||
def wanted():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -221,7 +222,7 @@ def wanted_search_missing_subtitles_list():
|
|||
|
||||
@route(base_url + 'settings')
|
||||
def settings():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_general")
|
||||
settings_general = c.fetchone()
|
||||
|
@ -238,7 +239,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'))
|
||||
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = conn.cursor()
|
||||
|
||||
settings_general_ip = request.forms.get('settings_general_ip')
|
||||
|
@ -437,7 +438,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'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
c.execute("SELECT name FROM table_settings_providers WHERE enabled = 1")
|
||||
providers = c.fetchall()
|
||||
|
|
|
@ -7,7 +7,7 @@ from list_subtitles import *
|
|||
|
||||
def update_all_episodes():
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
@ -67,7 +67,7 @@ def update_all_episodes():
|
|||
|
||||
def add_new_episodes():
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
import ast
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
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
|
||||
|
|
|
@ -8,7 +8,7 @@ langs = [[lang.alpha_3,lang.alpha_2,lang.name]
|
|||
if hasattr(lang, 'alpha_2')]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Insert languages in database table
|
||||
|
|
|
@ -6,7 +6,7 @@ from subliminal import *
|
|||
providers_list = sorted(provider_manager.names())
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Insert providers in database table
|
||||
|
|
|
@ -6,7 +6,7 @@ from get_sonarr_settings import *
|
|||
|
||||
def update_series():
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
if apikey_sonarr == None:
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
import ast
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
|
|
@ -30,7 +30,7 @@ def download_subtitle(path, language, hi, providers):
|
|||
return None
|
||||
|
||||
def series_download_subtitles(no):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), tmieout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes_details = c_db.execute("SELECT path, missing_subtitles, sonarrEpisodeId FROM table_episodes WHERE sonarrSeriesId = ?", (no,)).fetchall()
|
||||
series_details = c_db.execute("SELECT hearing_impaired FROM table_shows WHERE sonarrSeriesId = ?", (no,)).fetchone()
|
||||
|
@ -50,7 +50,7 @@ def series_download_subtitles(no):
|
|||
list_missing_subtitles(no)
|
||||
|
||||
def wanted_download_subtitles(path):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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 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 name FROM table_settings_providers WHERE enabled = 1").fetchall()
|
||||
|
@ -69,7 +69,7 @@ def wanted_download_subtitles(path):
|
|||
history_log(1, episode[3], episode[2], message)
|
||||
|
||||
def wanted_search_missing_subtitles():
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ else:
|
|||
fd.close()
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Execute script and commit change to database
|
||||
|
|
|
@ -54,7 +54,7 @@ def store_subtitles(file):
|
|||
for subtitle, language in subtitles.iteritems():
|
||||
actual_subtitles.append([str(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'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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)))
|
||||
|
@ -70,7 +70,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'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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()
|
||||
|
@ -94,14 +94,14 @@ 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'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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()
|
||||
c_db.close()
|
||||
|
||||
def full_scan_subtitles():
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes = c_db.execute("SELECT path FROM table_episodes").fetchall()
|
||||
c_db.close()
|
||||
|
@ -110,7 +110,7 @@ def full_scan_subtitles():
|
|||
store_subtitles(path_replace(episode[0]))
|
||||
|
||||
def series_scan_subtitles(no):
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/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()
|
||||
|
@ -121,7 +121,7 @@ def series_scan_subtitles(no):
|
|||
list_missing_subtitles(no)
|
||||
|
||||
def new_scan_subtitles():
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
|
||||
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c_db = conn_db.cursor()
|
||||
episodes = c_db.execute("SELECT path FROM table_episodes WHERE subtitles is null").fetchall()
|
||||
c_db.close()
|
||||
|
|
25
update_db.py
Normal file
25
update_db.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import os
|
||||
import sqlite3
|
||||
|
||||
# Check if database exist
|
||||
if os.path.exists(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')) == True:
|
||||
# Open database connection
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Execute table modification
|
||||
try:
|
||||
c.execute('alter table table_settings_providers add column "username" "text"')
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
c.execute('alter table table_settings_providers add column "password" "text"')
|
||||
except:
|
||||
pass
|
||||
|
||||
# Commit change to db
|
||||
db.commit()
|
||||
|
||||
# Close database connection
|
||||
db.close()
|
2
utils.py
2
utils.py
|
@ -4,7 +4,7 @@ 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'))
|
||||
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'), timeout=30)
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
|
Loading…
Reference in a new issue