From 5d87b1047536efb42ee45d53a1ea85a0d536157d Mon Sep 17 00:00:00 2001 From: JayZed Date: Fri, 1 Mar 2024 14:43:09 -0500 Subject: [PATCH] Fixed subtitles synchronization process when settings values have changed since Bazarr started --- bazarr/subtitles/indexer/movies.py | 5 ++++- bazarr/subtitles/indexer/series.py | 5 ++++- bazarr/subtitles/sync.py | 15 +++++++++++++-- bazarr/subtitles/tools/subsyncer.py | 6 +++--- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/bazarr/subtitles/indexer/movies.py b/bazarr/subtitles/indexer/movies.py index 1fa9c0e6c..48c93001d 100644 --- a/bazarr/subtitles/indexer/movies.py +++ b/bazarr/subtitles/indexer/movies.py @@ -264,7 +264,10 @@ def list_missing_subtitles_movies(no=None, send_event=True): event_stream(type='badges') -def movies_full_scan_subtitles(use_cache=settings.radarr.use_ffprobe_cache): +def movies_full_scan_subtitles(use_cache=None): + if use_cache is None: + use_cache = settings.radarr.use_ffprobe_cache + movies = database.execute( select(TableMovies.path))\ .all() diff --git a/bazarr/subtitles/indexer/series.py b/bazarr/subtitles/indexer/series.py index 36014fa04..52622e9ea 100644 --- a/bazarr/subtitles/indexer/series.py +++ b/bazarr/subtitles/indexer/series.py @@ -266,7 +266,10 @@ def list_missing_subtitles(no=None, epno=None, send_event=True): event_stream(type='badges') -def series_full_scan_subtitles(use_cache=settings.sonarr.use_ffprobe_cache): +def series_full_scan_subtitles(use_cache=None): + if use_cache is None: + use_cache = settings.sonarr.use_ffprobe_cache + episodes = database.execute( select(TableEpisodes.path))\ .all() diff --git a/bazarr/subtitles/sync.py b/bazarr/subtitles/sync.py index 35f62bc46..dffc24fcb 100644 --- a/bazarr/subtitles/sync.py +++ b/bazarr/subtitles/sync.py @@ -26,8 +26,19 @@ def sync_subtitles(video_path, srt_path, srt_lang, forced, percent_score, sonarr if not use_subsync_threshold or (use_subsync_threshold and percent_score < float(subsync_threshold)): subsync = SubSyncer() - subsync.sync(video_path=video_path, srt_path=srt_path, srt_lang=srt_lang, - sonarr_series_id=sonarr_series_id, sonarr_episode_id=sonarr_episode_id, radarr_id=radarr_id) + sync_kwargs = { + 'video_path': video_path, + 'srt_path': srt_path, + 'srt_lang': srt_lang, + 'max_offset_seconds': str(settings.subsync.max_offset_seconds), + 'no_fix_framerate': settings.subsync.no_fix_framerate, + 'gss': settings.subsync.gss, + 'reference': None, # means choose automatically within video file + 'sonarr_series_id': sonarr_series_id, + 'sonarr_episode_id': sonarr_episode_id, + 'radarr_id': radarr_id, + } + subsync.sync(**sync_kwargs) del subsync gc.collect() return True diff --git a/bazarr/subtitles/tools/subsyncer.py b/bazarr/subtitles/tools/subsyncer.py index 88f2812a3..72364aa5e 100644 --- a/bazarr/subtitles/tools/subsyncer.py +++ b/bazarr/subtitles/tools/subsyncer.py @@ -30,9 +30,9 @@ class SubSyncer: self.vad = 'subs_then_webrtc' self.log_dir_path = os.path.join(args.config_dir, 'log') - def sync(self, video_path, srt_path, srt_lang, sonarr_series_id=None, sonarr_episode_id=None, radarr_id=None, - reference=None, max_offset_seconds=str(settings.subsync.max_offset_seconds), - no_fix_framerate=settings.subsync.no_fix_framerate, gss=settings.subsync.gss): + def sync(self, video_path, srt_path, srt_lang, + max_offset_seconds, no_fix_framerate, gss, reference=None, + sonarr_series_id=None, sonarr_episode_id=None, radarr_id=None): self.reference = video_path self.srtin = srt_path if self.srtin.casefold().endswith('.ass'):