Put log and db in data folder

pull/26/head
Louis Vézina 7 years ago
parent dcaa2ce0c8
commit 7d471ef0f2

4
.gitignore vendored

@ -1,9 +1,9 @@
*.pyc *.pyc
bazarr.db data/db/bazarr.db
cachefile.dbm cachefile.dbm
*.log *.log
*.log.* *.log.*
*.db *.db
*.pyc *.pyc
*.pyc *.pyc
bazarr.db data/db/bazarr.db

@ -1,7 +1,7 @@
FROM lsiobase/alpine.python FROM lsiobase/alpine.python
EXPOSE 6767 EXPOSE 6767
VOLUME /bazarr /tv VOLUME /bazarr/data /tv
# Update # Update
RUN apk add --update build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git RUN apk add --update build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git

@ -28,7 +28,7 @@ from utils import *
import logging import logging
from logging.handlers import TimedRotatingFileHandler from logging.handlers import TimedRotatingFileHandler
logger = logging.getLogger('waitress') logger = logging.getLogger('waitress')
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
c.execute("SELECT log_level FROM table_settings_general") c.execute("SELECT log_level FROM table_settings_general")
log_level = c.fetchone() log_level = c.fetchone()
@ -53,7 +53,7 @@ class OneLineExceptionFormatter(logging.Formatter):
return s return s
def configure_logging(): 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|', f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|',
'%d/%m/%Y %H:%M:%S') '%d/%m/%Y %H:%M:%S')
fh.setFormatter(f) fh.setFormatter(f)
@ -78,7 +78,7 @@ def image_proxy(url):
@route(base_url + '/') @route(base_url + '/')
def series(): def series():
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
db.create_function("path_substitution", 1, path_replace) db.create_function("path_substitution", 1, path_replace)
c = db.cursor() c = db.cursor()
c.execute("SELECT tvdbId, title, path_substitution(path), languages, hearing_impaired, sonarrSeriesId, poster FROM table_shows ORDER BY title") 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: else:
hi = "False" hi = "False"
conn = sqlite3.connect('bazarr.db') conn = sqlite3.connect('data/db/bazarr.db')
c = conn.cursor() c = conn.cursor()
c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE tvdbId LIKE ?", (str(lang), hi, no)) c.execute("UPDATE table_shows SET languages = ?, hearing_impaired = ? WHERE tvdbId LIKE ?", (str(lang), hi, no))
conn.commit() conn.commit()
@ -144,7 +144,7 @@ def add_new_episodes_list():
@route(base_url + '/episodes/<no:int>', method='GET') @route(base_url + '/episodes/<no:int>', method='GET')
def episodes(no): def episodes(no):
conn = sqlite3.connect('bazarr.db') conn = sqlite3.connect('data/db/bazarr.db')
conn.create_function("path_substitution", 1, path_replace) conn.create_function("path_substitution", 1, path_replace)
c = conn.cursor() c = conn.cursor()
@ -178,7 +178,7 @@ def search_missing_subtitles(no):
@route(base_url + '/history') @route(base_url + '/history')
def history(): def history():
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
c.execute("SELECT COUNT(*) FROM table_history") c.execute("SELECT COUNT(*) FROM table_history")
@ -198,7 +198,7 @@ def history():
@route(base_url + '/wanted') @route(base_url + '/wanted')
def wanted(): def wanted():
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
db.create_function("path_substitution", 1, path_replace) db.create_function("path_substitution", 1, path_replace)
c = db.cursor() c = db.cursor()
@ -220,7 +220,7 @@ def wanted():
def wanted_search_missing_subtitles(): def wanted_search_missing_subtitles():
ref = request.environ['HTTP_REFERER'] 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) db.create_function("path_substitution", 1, path_replace)
c = db.cursor() c = db.cursor()
@ -235,7 +235,7 @@ def wanted_search_missing_subtitles():
@route(base_url + '/settings') @route(base_url + '/settings')
def settings(): def settings():
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
c.execute("SELECT * FROM table_settings_general") c.execute("SELECT * FROM table_settings_general")
settings_general = c.fetchone() settings_general = c.fetchone()
@ -252,7 +252,7 @@ def settings():
def save_settings(): def save_settings():
ref = request.environ['HTTP_REFERER'] ref = request.environ['HTTP_REFERER']
conn = sqlite3.connect('bazarr.db') conn = sqlite3.connect('data/db/bazarr.db')
c = conn.cursor() c = conn.cursor()
settings_general_ip = request.forms.get('settings_general_ip') settings_general_ip = request.forms.get('settings_general_ip')
@ -292,14 +292,14 @@ def save_settings():
@route(base_url + '/system') @route(base_url + '/system')
def system(): def system():
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
c.execute("SELECT * FROM table_scheduler") c.execute("SELECT * FROM table_scheduler")
tasks = c.fetchall() tasks = c.fetchall()
c.close() c.close()
logs = [] logs = []
for line in reversed(open('bazarr.log').readlines()): for line in reversed(open('data/log/bazarr.log').readlines()):
logs.append(line.rstrip()) logs.append(line.rstrip())
return template('system', tasks=tasks, logs=logs, base_url=base_url) return template('system', tasks=tasks, logs=logs, base_url=base_url)
@ -331,7 +331,7 @@ def get_subtitle():
sonarrSeriesId = request.forms.get('sonarrSeriesId') sonarrSeriesId = request.forms.get('sonarrSeriesId')
sonarrEpisodeId = request.forms.get('sonarrEpisodeId') sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
c.execute("SELECT name FROM table_settings_providers WHERE enabled = 1") c.execute("SELECT name FROM table_settings_providers WHERE enabled = 1")
providers = c.fetchall() providers = c.fetchall()

@ -6,7 +6,7 @@ from list_subtitles import *
def update_all_episodes(): def update_all_episodes():
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Get Sonarr API URL from database config table # Get Sonarr API URL from database config table
@ -65,7 +65,7 @@ def update_all_episodes():
def add_new_episodes(): def add_new_episodes():
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Get Sonarr API URL from database config table # Get Sonarr API URL from database config table

@ -3,7 +3,7 @@ import os
import ast import ast
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Get general settings from database table # Get general settings from database table

@ -7,7 +7,7 @@ langs = [[lang.alpha_3,lang.alpha_2,lang.name]
if hasattr(lang, 'alpha_2')] if hasattr(lang, 'alpha_2')]
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Insert languages in database table # Insert languages in database table

@ -5,7 +5,7 @@ from subliminal import *
providers_list = sorted(provider_manager.names()) providers_list = sorted(provider_manager.names())
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Insert providers in database table # Insert providers in database table

@ -6,7 +6,7 @@ from get_sonarr_settings import *
def update_series(): def update_series():
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Get shows data from Sonarr # Get shows data from Sonarr

@ -3,7 +3,7 @@ import os
import ast import ast
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Get Sonarr API URL from database config table # Get Sonarr API URL from database config table

@ -27,7 +27,7 @@ def download_subtitle(path, language, hi, providers):
return None return None
def series_download_subtitles(no): def series_download_subtitles(no):
conn_db = sqlite3.connect('bazarr.db') conn_db = sqlite3.connect('data/db/bazarr.db')
c_db = conn_db.cursor() c_db = conn_db.cursor()
episodes_details = c_db.execute("SELECT path, missing_subtitles, sonarrEpisodeId FROM table_episodes WHERE path = ?", (no,)).fetchall() 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() 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) list_missing_subtitles(no)
def wanted_download_subtitles(path): def wanted_download_subtitles(path):
conn_db = sqlite3.connect('bazarr.db') conn_db = sqlite3.connect('data/db/bazarr.db')
c_db = conn_db.cursor() 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() 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() enabled_providers = c_db.execute("SELECT name FROM table_settings_providers WHERE enabled = 1").fetchall()

@ -2,7 +2,7 @@ import os.path
import sqlite3 import sqlite3
# Check if database exist # Check if database exist
if os.path.exists('bazarr.db') == True: if os.path.exists('data/db/bazarr.db') == True:
pass pass
else: else:
# Get SQL script from file # Get SQL script from file
@ -10,7 +10,7 @@ else:
script = fd.read() script = fd.read()
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Execute script and commit change to database # Execute script and commit change to database

@ -49,7 +49,7 @@ def store_subtitles(file):
except: except:
pass pass
conn_db = sqlite3.connect('bazarr.db') conn_db = sqlite3.connect('data/db/bazarr.db')
c_db = conn_db.cursor() c_db = conn_db.cursor()
subtitles = core.search_external_subtitles(file) subtitles = core.search_external_subtitles(file)
@ -71,7 +71,7 @@ def list_missing_subtitles(*no):
query_string = " WHERE table_episodes.sonarrSeriesId = " + str(no[0]) query_string = " WHERE table_episodes.sonarrSeriesId = " + str(no[0])
except: except:
pass pass
conn_db = sqlite3.connect('bazarr.db') conn_db = sqlite3.connect('data/db/bazarr.db')
c_db = conn_db.cursor() 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() 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() c_db.close()
def full_scan_subtitles(): def full_scan_subtitles():
conn_db = sqlite3.connect('bazarr.db') conn_db = sqlite3.connect('data/db/bazarr.db')
c_db = conn_db.cursor() c_db = conn_db.cursor()
episodes = c_db.execute("SELECT path FROM table_episodes").fetchall() episodes = c_db.execute("SELECT path FROM table_episodes").fetchall()
c_db.close() c_db.close()
@ -109,7 +109,7 @@ def full_scan_subtitles():
store_subtitles(path_replace(episode[0])) store_subtitles(path_replace(episode[0]))
def series_scan_subtitles(no): def series_scan_subtitles(no):
conn_db = sqlite3.connect('bazarr.db') conn_db = sqlite3.connect('data/db/bazarr.db')
c_db = conn_db.cursor() c_db = conn_db.cursor()
episodes = c_db.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId = ?", (no,)).fetchall() episodes = c_db.execute("SELECT path FROM table_episodes WHERE sonarrSeriesId = ?", (no,)).fetchall()
c_db.close() c_db.close()
@ -120,7 +120,7 @@ def series_scan_subtitles(no):
list_missing_subtitles(no) list_missing_subtitles(no)
def new_scan_subtitles(): def new_scan_subtitles():
conn_db = sqlite3.connect('bazarr.db') conn_db = sqlite3.connect('data/db/bazarr.db')
c_db = conn_db.cursor() c_db = conn_db.cursor()
episodes = c_db.execute("SELECT path FROM table_episodes WHERE subtitles is null").fetchall() episodes = c_db.execute("SELECT path FROM table_episodes WHERE subtitles is null").fetchall()
c_db.close() c_db.close()

@ -3,7 +3,7 @@ import time
def history_log(action, sonarrSeriesId, sonarrEpisodeId, description): def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
# Open database connection # Open database connection
db = sqlite3.connect('bazarr.db') db = sqlite3.connect('data/db/bazarr.db')
c = db.cursor() c = db.cursor()
# Get Sonarr API URL from database config table # Get Sonarr API URL from database config table

Loading…
Cancel
Save