Continuing development.

pull/543/head
Louis Vézina 5 years ago
parent 266ddbb9db
commit feaa29a640

@ -14,10 +14,6 @@ database = SqliteQueueDatabase(
queue_max_size=256, # Max. # of pending writes that can accumulate. queue_max_size=256, # Max. # of pending writes that can accumulate.
results_timeout=30.0) # Max. time to wait for query to be executed. results_timeout=30.0) # Max. time to wait for query to be executed.
#database = SqliteDatabase(os.path.join(args.config_dir, 'db', 'bazarr.db'), pragmas={
# 'journal_mode': 'wal',
# 'cache_size': -1024 * 8})
@database.func('path_substitution') @database.func('path_substitution')
def path_substitution(path): def path_substitution(path):
@ -174,6 +170,11 @@ class TableSettingsNotifier(BaseModel):
def database_init(): def database_init():
database.connect() database.connect()
database.pragma('wal_checkpoint', 'TRUNCATE') # Run a checkpoint and merge remaining wal-journal.
database.cache_size = -1024 # Number of KB of cache for wal-journal.
# Must be negative because positive means number of pages.
database.wal_autocheckpoint = 50 # Run an automatic checkpoint every 50 write transactions.
models_list = [TableShows, TableEpisodes, TableMovies, TableHistory, TableHistoryMovie, TableSettingsLanguages, models_list = [TableShows, TableEpisodes, TableMovies, TableHistory, TableHistoryMovie, TableSettingsLanguages,
TableSettingsNotifier, System] TableSettingsNotifier, System]
@ -189,6 +190,11 @@ def database_init():
).execute() ).execute()
def wal_cleaning():
database.pragma('wal_checkpoint', 'TRUNCATE') # Run a checkpoint and merge remaining wal-journal.
database.wal_autocheckpoint = 50 # Run an automatic checkpoint every 50 write transactions.
@atexit.register @atexit.register
def _stop_worker_threads(): def _stop_worker_threads():
database.close() database.close()

@ -4,13 +4,12 @@ import requests
import logging import logging
import re import re
from queueconfig import notifications from queueconfig import notifications
from database import TableShows, TableEpisodes from database import TableShows, TableEpisodes, wal_cleaning
from get_args import args from get_args import args
from config import settings, url_sonarr from config import settings, url_sonarr
from helper import path_replace from helper import path_replace
from list_subtitles import list_missing_subtitles, store_subtitles, series_full_scan_subtitles, \ from list_subtitles import list_missing_subtitles, store_subtitles, series_full_scan_subtitles
movies_full_scan_subtitles
from get_subtitle import episode_download_subtitles from get_subtitle import episode_download_subtitles
@ -19,13 +18,7 @@ def update_all_episodes():
logging.info('BAZARR All existing episode subtitles indexed from disk.') logging.info('BAZARR All existing episode subtitles indexed from disk.')
list_missing_subtitles() list_missing_subtitles()
logging.info('BAZARR All missing episode subtitles updated in database.') logging.info('BAZARR All missing episode subtitles updated in database.')
wal_cleaning()
def update_all_movies():
movies_full_scan_subtitles()
logging.info('BAZARR All existing movie subtitles indexed from disk.')
list_missing_subtitles()
logging.info('BAZARR All missing movie subtitles updated in database.')
def sync_episodes(): def sync_episodes():

@ -8,9 +8,18 @@ from queueconfig import notifications
from get_args import args from get_args import args
from config import settings, url_radarr from config import settings, url_radarr
from helper import path_replace_movie from helper import path_replace_movie
from list_subtitles import store_subtitles_movie, list_missing_subtitles_movies from list_subtitles import store_subtitles_movie, list_missing_subtitles_movies, movies_full_scan_subtitles
from get_subtitle import movies_download_subtitles from get_subtitle import movies_download_subtitles
from database import TableMovies from database import TableMovies, wal_cleaning
def update_all_movies():
movies_full_scan_subtitles()
logging.info('BAZARR All existing movie subtitles indexed from disk.')
list_missing_subtitles_movies()
logging.info('BAZARR All missing movie subtitles updated in database.')
wal_cleaning()
def update_movies(): def update_movies():

@ -32,7 +32,6 @@ def store_subtitles(file):
logging.debug('BAZARR started subtitles indexing for this file: ' + file) logging.debug('BAZARR started subtitles indexing for this file: ' + file)
actual_subtitles = [] actual_subtitles = []
if os.path.exists(file): if os.path.exists(file):
# notifications.write(msg='Analyzing this file for subtitles: ' + file, queue='list_subtitles')
if settings.general.getboolean('use_embedded_subs'): if settings.general.getboolean('use_embedded_subs'):
logging.debug("BAZARR is trying to index embedded subtitles.") logging.debug("BAZARR is trying to index embedded subtitles.")
try: try:

@ -1,7 +1,7 @@
# coding=utf-8 # coding=utf-8
from get_episodes import sync_episodes, update_all_episodes, update_all_movies from get_episodes import sync_episodes, update_all_episodes
from get_movies import update_movies from get_movies import update_movies, update_all_movies
from get_series import update_series from get_series import update_series
from config import settings from config import settings
from get_subtitle import wanted_search_missing_subtitles, upgrade_subtitles from get_subtitle import wanted_search_missing_subtitles, upgrade_subtitles

Loading…
Cancel
Save