Use absolute path

pull/26/head
Louis Vézina 7 years ago
parent 5c52b5111e
commit ded69fe6e7

4
.gitignore vendored

@ -1,9 +1,9 @@
*.pyc
data/db/bazarr.db
os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')
cachefile.dbm
*.log
*.log.*
*.db
*.pyc
*.pyc
data/db/bazarr.db
os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db')

@ -1,18 +1,14 @@
FROM lsiobase/alpine.python
EXPOSE 6767
VOLUME /tv
VOLUME /tv /bazarr/data
# Update
RUN apk add --update build-base python-dev py2-pip py-setuptools jpeg-dev zlib-dev git
WORKDIR /bazarr
# Get application source from Github
RUN git clone -b master --single-branch https://github.com/morpheus65535/bazarr.git /bazarr
VOLUME /bazarr/data
# Install app dependencies
RUN pip install -r /bazarr/requirements.txt

@ -4,6 +4,7 @@ bottle.debug(True)
bottle.TEMPLATES.clear()
import sqlite3
import os
import itertools
import operator
import requests
@ -28,7 +29,7 @@ from utils import *
import logging
from logging.handlers import TimedRotatingFileHandler
logger = logging.getLogger('waitress')
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
c.execute("SELECT log_level FROM table_settings_general")
log_level = c.fetchone()
@ -53,7 +54,7 @@ class OneLineExceptionFormatter(logging.Formatter):
return s
def configure_logging():
fh = TimedRotatingFileHandler('data/log/bazarr.log', when="midnight", interval=1, backupCount=7)
fh = TimedRotatingFileHandler(os.path.join(os.path.dirname(__file__), '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 +79,7 @@ def image_proxy(url):
@route(base_url + '/')
def series():
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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 +109,7 @@ def edit_series(no):
else:
hi = "False"
conn = sqlite3.connect('data/db/bazarr.db')
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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 +145,7 @@ def add_new_episodes_list():
@route(base_url + '/episodes/<no:int>', method='GET')
def episodes(no):
conn = sqlite3.connect('data/db/bazarr.db')
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
conn.create_function("path_substitution", 1, path_replace)
c = conn.cursor()
@ -178,7 +179,7 @@ def search_missing_subtitles(no):
@route(base_url + '/history')
def history():
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
c.execute("SELECT COUNT(*) FROM table_history")
@ -198,7 +199,7 @@ def history():
@route(base_url + '/wanted')
def wanted():
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
db.create_function("path_substitution", 1, path_replace)
c = db.cursor()
@ -220,7 +221,7 @@ def wanted():
def wanted_search_missing_subtitles():
ref = request.environ['HTTP_REFERER']
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
db.create_function("path_substitution", 1, path_replace)
c = db.cursor()
@ -235,7 +236,7 @@ def wanted_search_missing_subtitles():
@route(base_url + '/settings')
def settings():
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
c.execute("SELECT * FROM table_settings_general")
settings_general = c.fetchone()
@ -252,7 +253,7 @@ def settings():
def save_settings():
ref = request.environ['HTTP_REFERER']
conn = sqlite3.connect('data/db/bazarr.db')
conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = conn.cursor()
settings_general_ip = request.forms.get('settings_general_ip')
@ -292,14 +293,14 @@ def save_settings():
@route(base_url + '/system')
def system():
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
c.execute("SELECT * FROM table_scheduler")
tasks = c.fetchall()
c.close()
logs = []
for line in reversed(open('data/log/bazarr.log').readlines()):
for line in reversed(open(os.path.join(os.path.dirname(__file__), 'data/log/bazarr.log')).readlines()):
logs.append(line.rstrip())
return template('system', tasks=tasks, logs=logs, base_url=base_url)
@ -331,7 +332,7 @@ def get_subtitle():
sonarrSeriesId = request.forms.get('sonarrSeriesId')
sonarrEpisodeId = request.forms.get('sonarrEpisodeId')
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
c.execute("SELECT name FROM table_settings_providers WHERE enabled = 1")
providers = c.fetchall()

@ -1,3 +1,4 @@
import os
import sqlite3
import requests
@ -6,7 +7,7 @@ from list_subtitles import *
def update_all_episodes():
# Open database connection
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
# Get Sonarr API URL from database config table
@ -65,7 +66,7 @@ def update_all_episodes():
def add_new_episodes():
# Open database connection
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
# Get general settings from database table

@ -1,5 +1,6 @@
import sqlite3
import pycountry
import os
# Get languages list in langs tuple
langs = [[lang.alpha_3,lang.alpha_2,lang.name]
@ -7,7 +8,7 @@ langs = [[lang.alpha_3,lang.alpha_2,lang.name]
if hasattr(lang, 'alpha_2')]
# Open database connection
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
# Insert languages in database table

@ -1,11 +1,12 @@
import sqlite3
import os
from subliminal import *
# Get providers list from subliminal
providers_list = sorted(provider_manager.names())
# Open database connection
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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()

@ -1,8 +1,8 @@
import os.path
import os
import sqlite3
# Check if database exist
if os.path.exists('data/db/bazarr.db') == True:
if os.path.exists(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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('data/db/bazarr.db')
conn_db = sqlite3.connect(os.path.join(os.path.dirname(__file__), '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()

@ -1,9 +1,10 @@
import os
import sqlite3
import time
def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
# Open database connection
db = sqlite3.connect('data/db/bazarr.db')
db = sqlite3.connect(os.path.join(os.path.dirname(__file__), 'data/db/bazarr.db'))
c = db.cursor()
# Get Sonarr API URL from database config table

Loading…
Cancel
Save