mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-30 18:47:59 +08:00
Put log and db in data folder
This commit is contained in:
parent
dcaa2ce0c8
commit
7d471ef0f2
13 changed files with 33 additions and 33 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,9 +1,9 @@
|
|||
*.pyc
|
||||
bazarr.db
|
||||
data/db/bazarr.db
|
||||
cachefile.dbm
|
||||
*.log
|
||||
*.log.*
|
||||
*.db
|
||||
*.pyc
|
||||
*.pyc
|
||||
bazarr.db
|
||||
data/db/bazarr.db
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FROM lsiobase/alpine.python
|
||||
|
||||
EXPOSE 6767
|
||||
VOLUME /bazarr /tv
|
||||
VOLUME /bazarr/data /tv
|
||||
|
||||
# Update
|
||||
RUN apk add --update build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git
|
||||
|
|
26
bazarr.py
26
bazarr.py
|
@ -28,7 +28,7 @@ from utils import *
|
|||
import logging
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
logger = logging.getLogger('waitress')
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
c.execute("SELECT log_level FROM table_settings_general")
|
||||
log_level = c.fetchone()
|
||||
|
@ -53,7 +53,7 @@ class OneLineExceptionFormatter(logging.Formatter):
|
|||
return s
|
||||
|
||||
def configure_logging():
|
||||
fh = TimedRotatingFileHandler('bazarr.log', when="midnight", interval=1, backupCount=7)
|
||||
fh = TimedRotatingFileHandler('data/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)
|
||||
|
@ -78,7 +78,7 @@ def image_proxy(url):
|
|||
|
||||
@route(base_url + '/')
|
||||
def series():
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
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")
|
||||
|
@ -108,7 +108,7 @@ def edit_series(no):
|
|||
else:
|
||||
hi = "False"
|
||||
|
||||
conn = sqlite3.connect('bazarr.db')
|
||||
conn = sqlite3.connect('data/db/bazarr.db')
|
||||
c = conn.cursor()
|
||||
c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE tvdbId LIKE ?", (str(lang), hi, no))
|
||||
conn.commit()
|
||||
|
@ -144,7 +144,7 @@ def add_new_episodes_list():
|
|||
|
||||
@route(base_url + '/episodes/<no:int>', method='GET')
|
||||
def episodes(no):
|
||||
conn = sqlite3.connect('bazarr.db')
|
||||
conn = sqlite3.connect('data/db/bazarr.db')
|
||||
conn.create_function("path_substitution", 1, path_replace)
|
||||
c = conn.cursor()
|
||||
|
||||
|
@ -178,7 +178,7 @@ def search_missing_subtitles(no):
|
|||
|
||||
@route(base_url + '/history')
|
||||
def history():
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
c.execute("SELECT COUNT(*) FROM table_history")
|
||||
|
@ -198,7 +198,7 @@ def history():
|
|||
|
||||
@route(base_url + '/wanted')
|
||||
def wanted():
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -220,7 +220,7 @@ def wanted():
|
|||
def wanted_search_missing_subtitles():
|
||||
ref = request.environ['HTTP_REFERER']
|
||||
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
db.create_function("path_substitution", 1, path_replace)
|
||||
c = db.cursor()
|
||||
|
||||
|
@ -235,7 +235,7 @@ def wanted_search_missing_subtitles():
|
|||
|
||||
@route(base_url + '/settings')
|
||||
def settings():
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_settings_general")
|
||||
settings_general = c.fetchone()
|
||||
|
@ -252,7 +252,7 @@ def settings():
|
|||
def save_settings():
|
||||
ref = request.environ['HTTP_REFERER']
|
||||
|
||||
conn = sqlite3.connect('bazarr.db')
|
||||
conn = sqlite3.connect('data/db/bazarr.db')
|
||||
c = conn.cursor()
|
||||
|
||||
settings_general_ip = request.forms.get('settings_general_ip')
|
||||
|
@ -292,14 +292,14 @@ def save_settings():
|
|||
|
||||
@route(base_url + '/system')
|
||||
def system():
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
c.execute("SELECT * FROM table_scheduler")
|
||||
tasks = c.fetchall()
|
||||
c.close()
|
||||
|
||||
logs = []
|
||||
for line in reversed(open('bazarr.log').readlines()):
|
||||
for line in reversed(open('data/log/bazarr.log').readlines()):
|
||||
logs.append(line.rstrip())
|
||||
|
||||
return template('system', tasks=tasks, logs=logs, base_url=base_url)
|
||||
|
@ -331,7 +331,7 @@ def get_subtitle():
|
|||
sonarrSeriesId = request.forms.get('sonarrSeriesId')
|
||||
sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
|
||||
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
c.execute("SELECT name FROM table_settings_providers WHERE enabled = 1")
|
||||
providers = c.fetchall()
|
||||
|
|
|
@ -6,7 +6,7 @@ from list_subtitles import *
|
|||
|
||||
def update_all_episodes():
|
||||
# Open database connection
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
@ -65,7 +65,7 @@ def update_all_episodes():
|
|||
|
||||
def add_new_episodes():
|
||||
# Open database connection
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
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('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
# Get general settings from database table
|
||||
|
|
|
@ -7,7 +7,7 @@ langs = [[lang.alpha_3,lang.alpha_2,lang.name]
|
|||
if hasattr(lang, 'alpha_2')]
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
# Insert languages in database table
|
||||
|
|
|
@ -5,7 +5,7 @@ from subliminal import *
|
|||
providers_list = sorted(provider_manager.names())
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
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('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
# Get shows data from Sonarr
|
||||
|
|
|
@ -3,7 +3,7 @@ import os
|
|||
import ast
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
|
|
@ -27,7 +27,7 @@ def download_subtitle(path, language, hi, providers):
|
|||
return None
|
||||
|
||||
def series_download_subtitles(no):
|
||||
conn_db = sqlite3.connect('bazarr.db')
|
||||
conn_db = sqlite3.connect('data/db/bazarr.db')
|
||||
c_db = conn_db.cursor()
|
||||
episodes_details = c_db.execute("SELECT path, missing_subtitles, sonarrEpisodeId FROM table_episodes WHERE path = ?", (no,)).fetchall()
|
||||
series_details = c_db.execute("SELECT hearing_impaired FROM table_shows WHERE sonarrSeriesId = ?", (no,)).fetchone()
|
||||
|
@ -47,7 +47,7 @@ def series_download_subtitles(no):
|
|||
list_missing_subtitles(no)
|
||||
|
||||
def wanted_download_subtitles(path):
|
||||
conn_db = sqlite3.connect('bazarr.db')
|
||||
conn_db = sqlite3.connect('data/db/bazarr.db')
|
||||
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()
|
||||
|
|
|
@ -2,7 +2,7 @@ import os.path
|
|||
import sqlite3
|
||||
|
||||
# Check if database exist
|
||||
if os.path.exists('bazarr.db') == True:
|
||||
if os.path.exists('data/db/bazarr.db') == True:
|
||||
pass
|
||||
else:
|
||||
# Get SQL script from file
|
||||
|
@ -10,7 +10,7 @@ else:
|
|||
script = fd.read()
|
||||
|
||||
# Open database connection
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
# Execute script and commit change to database
|
||||
|
|
|
@ -49,7 +49,7 @@ def store_subtitles(file):
|
|||
except:
|
||||
pass
|
||||
|
||||
conn_db = sqlite3.connect('bazarr.db')
|
||||
conn_db = sqlite3.connect('data/db/bazarr.db')
|
||||
c_db = conn_db.cursor()
|
||||
|
||||
subtitles = core.search_external_subtitles(file)
|
||||
|
@ -71,7 +71,7 @@ def list_missing_subtitles(*no):
|
|||
query_string = " WHERE table_episodes.sonarrSeriesId = " + str(no[0])
|
||||
except:
|
||||
pass
|
||||
conn_db = sqlite3.connect('bazarr.db')
|
||||
conn_db = sqlite3.connect('data/db/bazarr.db')
|
||||
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()
|
||||
|
||||
|
@ -100,7 +100,7 @@ def list_missing_subtitles(*no):
|
|||
c_db.close()
|
||||
|
||||
def full_scan_subtitles():
|
||||
conn_db = sqlite3.connect('bazarr.db')
|
||||
conn_db = sqlite3.connect('data/db/bazarr.db')
|
||||
c_db = conn_db.cursor()
|
||||
episodes = c_db.execute("SELECT path FROM table_episodes").fetchall()
|
||||
c_db.close()
|
||||
|
@ -109,7 +109,7 @@ def full_scan_subtitles():
|
|||
store_subtitles(path_replace(episode[0]))
|
||||
|
||||
def series_scan_subtitles(no):
|
||||
conn_db = sqlite3.connect('bazarr.db')
|
||||
conn_db = sqlite3.connect('data/db/bazarr.db')
|
||||
c_db = conn_db.cursor()
|
||||
episodes = c_db.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId = ?", (no,)).fetchall()
|
||||
c_db.close()
|
||||
|
@ -120,7 +120,7 @@ def series_scan_subtitles(no):
|
|||
list_missing_subtitles(no)
|
||||
|
||||
def new_scan_subtitles():
|
||||
conn_db = sqlite3.connect('bazarr.db')
|
||||
conn_db = sqlite3.connect('data/db/bazarr.db')
|
||||
c_db = conn_db.cursor()
|
||||
episodes = c_db.execute("SELECT path FROM table_episodes WHERE subtitles is null").fetchall()
|
||||
c_db.close()
|
||||
|
|
2
utils.py
2
utils.py
|
@ -3,7 +3,7 @@ import time
|
|||
|
||||
def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
|
||||
# Open database connection
|
||||
db = sqlite3.connect('bazarr.db')
|
||||
db = sqlite3.connect('data/db/bazarr.db')
|
||||
c = db.cursor()
|
||||
|
||||
# Get Sonarr API URL from database config table
|
||||
|
|
Loading…
Reference in a new issue