From dcbd8130dba8f0568173f61a9614e30e24e9c54e Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Mon, 24 Jun 2024 10:59:10 -0400 Subject: [PATCH] Fixed HI or Forced status not being properly saved to history when syncing or translating a subtitles. --- bazarr/api/subtitles/subtitles.py | 6 ++++-- bazarr/subtitles/processing.py | 2 ++ bazarr/subtitles/sync.py | 4 +++- bazarr/subtitles/tools/subsyncer.py | 6 +++--- bazarr/subtitles/tools/translate.py | 4 ++-- bazarr/subtitles/upload.py | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bazarr/api/subtitles/subtitles.py b/bazarr/api/subtitles/subtitles.py index a83da76eb..06c5f0d77 100644 --- a/bazarr/api/subtitles/subtitles.py +++ b/bazarr/api/subtitles/subtitles.py @@ -114,6 +114,8 @@ class Subtitles(Resource): subtitles_path = args.get('path') media_type = args.get('type') id = args.get('id') + forced = True if args.get('forced') == 'True' else False + hi = True if args.get('hi') == 'True' else False if not os.path.exists(subtitles_path): return 'Subtitles file not found. Path mapping issue?', 500 @@ -144,6 +146,8 @@ class Subtitles(Resource): 'video_path': video_path, 'srt_path': subtitles_path, 'srt_lang': language, + 'hi': hi, + 'forced': forced, 'reference': args.get('reference') if args.get('reference') not in empty_values else video_path, 'max_offset_seconds': args.get('max_offset_seconds') if args.get('max_offset_seconds') not in empty_values else str(settings.subsync.max_offset_seconds), @@ -167,8 +171,6 @@ class Subtitles(Resource): elif action == 'translate': from_language = subtitles_lang_from_filename(subtitles_path) dest_language = language - forced = True if args.get('forced') == 'true' else False - hi = True if args.get('hi') == 'true' else False try: translate_subtitles_file(video_path=video_path, source_srt_file=subtitles_path, from_lang=from_language, to_lang=dest_language, forced=forced, hi=hi, diff --git a/bazarr/subtitles/processing.py b/bazarr/subtitles/processing.py index b5c032610..c008e72fa 100644 --- a/bazarr/subtitles/processing.py +++ b/bazarr/subtitles/processing.py @@ -88,6 +88,7 @@ def process_subtitle(subtitle, media_type, audio_language, path, max_score, is_u from .sync import sync_subtitles sync_subtitles(video_path=path, srt_path=downloaded_path, forced=subtitle.language.forced, + hi=subtitle.language.hi, srt_lang=downloaded_language_code2, percent_score=percent_score, sonarr_series_id=episode_metadata.sonarrSeriesId, @@ -106,6 +107,7 @@ def process_subtitle(subtitle, media_type, audio_language, path, max_score, is_u from .sync import sync_subtitles sync_subtitles(video_path=path, srt_path=downloaded_path, forced=subtitle.language.forced, + hi=subtitle.language.hi, srt_lang=downloaded_language_code2, percent_score=percent_score, radarr_id=movie_metadata.radarrId) diff --git a/bazarr/subtitles/sync.py b/bazarr/subtitles/sync.py index f7a3a69c4..4726d245f 100644 --- a/bazarr/subtitles/sync.py +++ b/bazarr/subtitles/sync.py @@ -8,7 +8,7 @@ from app.config import settings from subtitles.tools.subsyncer import SubSyncer -def sync_subtitles(video_path, srt_path, srt_lang, forced, percent_score, sonarr_series_id=None, +def sync_subtitles(video_path, srt_path, srt_lang, forced, hi, percent_score, sonarr_series_id=None, sonarr_episode_id=None, radarr_id=None): if forced: logging.debug('BAZARR cannot sync forced subtitles. Skipping sync routine.') @@ -30,6 +30,8 @@ def sync_subtitles(video_path, srt_path, srt_lang, forced, percent_score, sonarr 'video_path': video_path, 'srt_path': srt_path, 'srt_lang': srt_lang, + 'forced': forced, + 'hi': hi, 'max_offset_seconds': str(settings.subsync.max_offset_seconds), 'no_fix_framerate': settings.subsync.no_fix_framerate, 'gss': settings.subsync.gss, diff --git a/bazarr/subtitles/tools/subsyncer.py b/bazarr/subtitles/tools/subsyncer.py index a71424516..edde5c774 100644 --- a/bazarr/subtitles/tools/subsyncer.py +++ b/bazarr/subtitles/tools/subsyncer.py @@ -30,7 +30,7 @@ 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, + def sync(self, video_path, srt_path, srt_lang, hi, forced, max_offset_seconds, no_fix_framerate, gss, reference=None, sonarr_series_id=None, sonarr_episode_id=None, radarr_id=None): self.reference = video_path @@ -118,10 +118,10 @@ class SubSyncer: downloaded_language_code2=srt_lang, downloaded_provider=None, score=None, - forced=None, + forced=forced, subtitle_id=None, reversed_subtitles_path=srt_path, - hearing_impaired=None) + hearing_impaired=hi) if sonarr_episode_id: history_log(action=5, sonarr_series_id=sonarr_series_id, sonarr_episode_id=sonarr_episode_id, diff --git a/bazarr/subtitles/tools/translate.py b/bazarr/subtitles/tools/translate.py index d91c6a4ba..59e3542ad 100644 --- a/bazarr/subtitles/tools/translate.py +++ b/bazarr/subtitles/tools/translate.py @@ -94,10 +94,10 @@ def translate_subtitles_file(video_path, source_srt_file, from_lang, to_lang, fo downloaded_language_code2=to_lang, downloaded_provider=None, score=None, - forced=None, + forced=forced, subtitle_id=None, reversed_subtitles_path=dest_srt_file, - hearing_impaired=None) + hearing_impaired=hi) if media_type == 'series': history_log(action=6, sonarr_series_id=sonarr_series_id, sonarr_episode_id=sonarr_episode_id, result=result) diff --git a/bazarr/subtitles/upload.py b/bazarr/subtitles/upload.py index 8ad16128e..cd5aebca5 100644 --- a/bazarr/subtitles/upload.py +++ b/bazarr/subtitles/upload.py @@ -138,7 +138,7 @@ def manual_upload_subtitle(path, language, forced, hi, media_type, subtitle, aud series_id = episode_metadata.sonarrSeriesId episode_id = episode_metadata.sonarrEpisodeId sync_subtitles(video_path=path, srt_path=subtitle_path, srt_lang=uploaded_language_code2, percent_score=100, - sonarr_series_id=episode_metadata.sonarrSeriesId, forced=forced, + sonarr_series_id=episode_metadata.sonarrSeriesId, forced=forced, hi=hi, sonarr_episode_id=episode_metadata.sonarrEpisodeId) else: if not movie_metadata: @@ -146,7 +146,7 @@ def manual_upload_subtitle(path, language, forced, hi, media_type, subtitle, aud series_id = "" episode_id = movie_metadata.radarrId sync_subtitles(video_path=path, srt_path=subtitle_path, srt_lang=uploaded_language_code2, percent_score=100, - radarr_id=movie_metadata.radarrId, forced=forced) + radarr_id=movie_metadata.radarrId, forced=forced, hi=hi) if use_postprocessing: command = pp_replace(postprocessing_cmd, path, subtitle_path, uploaded_language, uploaded_language_code2,