Skip to content

Commit

Permalink
Fixed subtitles synchronization process when settings values have cha…
Browse files Browse the repository at this point in the history
…nged since Bazarr started
  • Loading branch information
JaiZed committed Mar 1, 2024
1 parent af37037 commit 5d87b10
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
5 changes: 4 additions & 1 deletion bazarr/subtitles/indexer/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion bazarr/subtitles/indexer/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
15 changes: 13 additions & 2 deletions bazarr/subtitles/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions bazarr/subtitles/tools/subsyncer.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def __init__(self):
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'):
Expand Down

0 comments on commit 5d87b10

Please sign in to comment.