Major fixes to database subsystem.

pull/684/head
Louis Vézina 5 years ago
parent ae6f7117fc
commit 698bca14b4

@ -16,8 +16,6 @@ from get_subtitle import episode_download_subtitles
def update_all_episodes():
series_full_scan_subtitles()
logging.info('BAZARR All existing episode subtitles indexed from disk.')
list_missing_subtitles()
logging.info('BAZARR All missing episode subtitles updated in database.')
wal_cleaning()
@ -172,8 +170,7 @@ def sync_episodes():
added_episode
).on_conflict_ignore().execute()
altered_episodes.append([added_episode['sonarr_episode_id'],
added_episode['path'],
added_episode['sonarr_series_id']])
added_episode['path']])
# Remove old episodes from DB
removed_episodes = list(set(current_episodes_db_list) - set(current_episodes_sonarr))
@ -188,7 +185,6 @@ def sync_episodes():
notifications.write(msg='Indexing episodes embedded subtitles...', queue='get_episodes', item=i,
length=len(altered_episodes))
store_subtitles(path_replace(altered_episode[1]))
list_missing_subtitles(altered_episode[2])
logging.debug('BAZARR All episodes synced from Sonarr into database.')

@ -18,8 +18,6 @@ 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()
@ -269,7 +267,6 @@ def update_movies():
notifications.write(msg='Indexing movies embedded subtitles...', queue='get_movies', item=i,
length=len(altered_movies))
store_subtitles_movie(path_replace_movie(altered_movie[1]))
list_missing_subtitles_movies(altered_movie[2])
logging.debug('BAZARR All movies synced from Radarr into database.')

@ -156,7 +156,7 @@ def update_series():
TableShows.insert(
added_series
).on_conflict_ignore().execute()
list_missing_subtitles(added_series['sonarr_series_id'])
list_missing_subtitles(no=added_series['sonarr_series_id'])
# Remove old series from DB
removed_series = list(set(current_shows_db_list) - set(current_shows_sonarr))

@ -611,7 +611,6 @@ def series_download_subtitles(no):
notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long')
logging.info("BAZARR All providers are throttled")
break
list_missing_subtitles(no)
if count_episodes_details:
notifications.write(msg='Search Complete. Please Reload The Page.', type='success', duration='permanent',
@ -671,7 +670,6 @@ def episode_download_subtitles(no):
store_subtitles(path_replace(episode.path))
history_log(1, episode.sonarr_series_id, episode.sonarr_episode_id, message, path, language_code, provider, score)
send_notifications(episode.sonarr_series_id, episode.sonarr_episode_id, message)
list_missing_subtitles(episode.sonarr_series_id)
else:
notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long')
logging.info("BAZARR All providers are throttled")
@ -724,7 +722,6 @@ def movies_download_subtitles(no):
notifications.write(msg='BAZARR All providers are throttled', queue='get_subtitle', duration='long')
logging.info("BAZARR All providers are throttled")
break
list_missing_subtitles_movies(no)
if count_movie:
notifications.write(msg='Search Complete. Please Reload The Page.', type='success', duration='permanent',
@ -796,7 +793,6 @@ def wanted_download_subtitles(path, l, count_episodes):
provider = result[3]
score = result[4]
store_subtitles(path_replace(episode.path))
list_missing_subtitles(episode.sonarr_series_id.sonarr_series_id)
history_log(1, episode.sonarr_series_id.sonarr_series_id, episode.sonarr_episode_id, message, path, language_code, provider, score)
send_notifications(episode.sonarr_series_id.sonarr_series_id, episode.sonarr_episode_id, message)
else:
@ -865,7 +861,6 @@ def wanted_download_subtitles_movie(path, l, count_movies):
provider = result[3]
score = result[4]
store_subtitles_movie(path_replace_movie(movie.path))
list_missing_subtitles_movies(movie.radarr_id)
history_log_movie(1, movie.radarr_id, message, path, language_code, provider, score)
send_notifications_movie(movie.radarr_id, message)
else:

@ -120,7 +120,15 @@ def store_subtitles(file):
logging.debug("BAZARR this file doesn't seems to exist or isn't accessible.")
logging.debug('BAZARR ended subtitles indexing for this file: ' + file)
episode = TableEpisodes.select(
TableEpisodes.sonarr_episode_id
).where(
TableEpisodes.path == path_replace_reverse(file)
).first()
list_missing_subtitles(epno=episode.sonarr_episode_id)
return actual_subtitles
@ -217,14 +225,24 @@ def store_subtitles_movie(file):
logging.debug("BAZARR this file doesn't seems to exist or isn't accessible.")
logging.debug('BAZARR ended subtitles indexing for this file: ' + file)
movie = TableMovies.select(
TableMovies.radarr_id
).where(
TableMovies.path == path_replace_reverse_movie(file)
).first()
list_missing_subtitles_movies(no=movie.radarr_id)
return actual_subtitles
def list_missing_subtitles(no=None):
def list_missing_subtitles(no=None, epno=None):
episodes_subtitles_clause = (TableShows.sonarr_series_id.is_null(False))
if no is not None:
episodes_subtitles_clause = (TableShows.sonarr_series_id == no)
elif epno is not None:
episodes_subtitles_clause = (TableEpisodes.sonarr_episode_id == epno)
episodes_subtitles = TableEpisodes.select(
TableShows.sonarr_series_id,
TableEpisodes.sonarr_episode_id,
@ -388,8 +406,6 @@ def series_scan_subtitles(no):
for episode in episodes:
store_subtitles(path_replace(episode.path))
list_missing_subtitles(no)
def movies_scan_subtitles(no):
@ -401,8 +417,6 @@ def movies_scan_subtitles(no):
for movie in movies:
store_subtitles_movie(path_replace_movie(movie.path))
list_missing_subtitles_movies(no)
def get_external_subtitles_path(file, subtitle):

@ -1,6 +1,6 @@
# coding=utf-8
bazarr_version = '0.8.2.4'
bazarr_version = '0.8.2.5'
import gc
import sys
@ -736,7 +736,7 @@ def edit_series(no):
TableShows.sonarr_series_id == no
).execute()
list_missing_subtitles(no)
list_missing_subtitles(no=no)
redirect(ref)
@ -784,7 +784,7 @@ def edit_serieseditor():
).execute()
for serie in series:
list_missing_subtitles(serie)
list_missing_subtitles(no=serie)
redirect(ref)
@ -2050,7 +2050,6 @@ def remove_subtitles():
except OSError as e:
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
store_subtitles(unicode(episodePath))
list_missing_subtitles(sonarrSeriesId)
@route(base_url + 'remove_subtitles_movie', method='POST')
@ -2069,7 +2068,6 @@ def remove_subtitles_movie():
except OSError as e:
logging.exception('BAZARR cannot delete subtitles file: ' + subtitlesPath)
store_subtitles_movie(unicode(moviePath))
list_missing_subtitles_movies(radarrId)
@route(base_url + 'get_subtitle', method='POST')
@ -2103,7 +2101,6 @@ def get_subtitle():
history_log(1, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
store_subtitles(unicode(episodePath))
list_missing_subtitles(sonarrSeriesId)
redirect(ref)
except OSError:
pass
@ -2161,7 +2158,6 @@ def manual_get_subtitle():
history_log(2, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
store_subtitles(unicode(episodePath))
list_missing_subtitles(sonarrSeriesId)
redirect(ref)
except OSError:
pass
@ -2205,7 +2201,6 @@ def perform_manual_upload_subtitle():
history_log(4, sonarrSeriesId, sonarrEpisodeId, message, path, language_code, provider, score)
send_notifications(sonarrSeriesId, sonarrEpisodeId, message)
store_subtitles(unicode(episodePath))
list_missing_subtitles(sonarrSeriesId)
redirect(ref)
except OSError:
@ -2242,7 +2237,6 @@ def get_subtitle_movie():
history_log_movie(1, radarrId, message, path, language_code, provider, score)
send_notifications_movie(radarrId, message)
store_subtitles_movie(unicode(moviePath))
list_missing_subtitles_movies(radarrId)
redirect(ref)
except OSError:
pass
@ -2298,7 +2292,6 @@ def manual_get_subtitle_movie():
history_log_movie(2, radarrId, message, path, language_code, provider, score)
send_notifications_movie(radarrId, message)
store_subtitles_movie(unicode(moviePath))
list_missing_subtitles_movies(radarrId)
redirect(ref)
except OSError:
pass
@ -2341,7 +2334,6 @@ def perform_manual_upload_subtitle_movie():
history_log_movie(4, radarrId, message, path, language_code, provider, score)
send_notifications_movie(radarrId, message)
store_subtitles_movie(unicode(moviePath))
list_missing_subtitles_movies(radarrId)
redirect(ref)
except OSError:

Loading…
Cancel
Save