From 30df4a8a2f1ca6e0cd60a33ff02c9a10405cc020 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Mon, 27 Jul 2020 07:31:15 -0400 Subject: [PATCH] Fix for #1033. --- bazarr/subsyncer.py | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/bazarr/subsyncer.py b/bazarr/subsyncer.py index 8932b6204..7ff162dfe 100644 --- a/bazarr/subsyncer.py +++ b/bazarr/subsyncer.py @@ -94,26 +94,32 @@ class SubSyncer: logging.debug('BAZARR FFmpeg used is %s', ffmpeg_exe) self.ffmpeg_path = os.path.dirname(ffmpeg_exe) - result = run(self) - - if result['sync_was_successful']: - message = "{0} subtitles synchronization ended with an offset of {1} seconds and a framerate scale factor" \ - " of {2} using {3} (0:{4}).".format(language_from_alpha3(srt_lang), result['offset_seconds'], - result['framerate_scale_factor'], using_what, - self.reference_stream) - - if media_type == 'series': - history_log(action=5, sonarr_series_id=sonarr_series_id, sonarr_episode_id=sonarr_episode_id, - description=message, video_path=path_mappings.path_replace_reverse(self.reference), - language=alpha2_from_alpha3(srt_lang), subtitles_path=srt_path) - else: - history_log_movie(action=5, radarr_id=radarr_id, description=message, - video_path=path_mappings.path_replace_reverse_movie(self.reference), - language=alpha2_from_alpha3(srt_lang), subtitles_path=srt_path) + try: + result = run(self) + except Exception as e: + logging.error('BAZARR an exception occurs during the synchronization process for this subtitles: ' + + self.srtin) else: - logging.error('BAZARR unable to sync subtitles: ' + self.srtin) + if result['sync_was_successful']: + message = "{0} subtitles synchronization ended with an offset of {1} seconds and a framerate scale " \ + "factor of {2} using {3} (0:{4}).".format(language_from_alpha3(srt_lang), + result['offset_seconds'], + result['framerate_scale_factor'], + using_what, + self.reference_stream) + + if media_type == 'series': + history_log(action=5, sonarr_series_id=sonarr_series_id, sonarr_episode_id=sonarr_episode_id, + description=message, video_path=path_mappings.path_replace_reverse(self.reference), + language=alpha2_from_alpha3(srt_lang), subtitles_path=srt_path) + else: + history_log_movie(action=5, radarr_id=radarr_id, description=message, + video_path=path_mappings.path_replace_reverse_movie(self.reference), + language=alpha2_from_alpha3(srt_lang), subtitles_path=srt_path) + else: + logging.error('BAZARR unable to sync subtitles: ' + self.srtin) - return result + return result class NoAudioTrack(Exception):