From 65c0e6b82393943797e36d94b2d1ce109cd46629 Mon Sep 17 00:00:00 2001 From: morpheus65535 Date: Mon, 3 Oct 2022 23:21:57 -0400 Subject: [PATCH] Fixed use original format when uploading subtitles. #1955 --- bazarr/subtitles/upload.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/bazarr/subtitles/upload.py b/bazarr/subtitles/upload.py index f69e37ce8..ec6c01a58 100644 --- a/bazarr/subtitles/upload.py +++ b/bazarr/subtitles/upload.py @@ -51,19 +51,6 @@ def manual_upload_subtitle(path, language, forced, hi, title, scene_name, media_ if forced: lang_obj = Language.rebuild(lang_obj, forced=True) - sub = Subtitle( - lang_obj, - mods=get_array_from(settings.general.subzero_mods) - ) - - sub.content = subtitle.read() - if not sub.is_valid(): - logging.exception('BAZARR Invalid subtitle file: ' + subtitle.filename) - sub.mods = None - - if settings.general.getboolean('utf8_encode'): - sub.set_encoding("utf-8") - if media_type == 'series': episode_metadata = TableEpisodes.select(TableEpisodes.sonarrSeriesId, TableEpisodes.sonarrEpisodeId, @@ -88,6 +75,20 @@ def manual_upload_subtitle(path, language, forced, hi, title, scene_name, media_ else: use_original_format = False + sub = Subtitle( + lang_obj, + mods=get_array_from(settings.general.subzero_mods), + original_format=use_original_format + ) + + sub.content = subtitle.read() + if not sub.is_valid(): + logging.exception('BAZARR Invalid subtitle file: ' + subtitle.filename) + sub.mods = None + + if settings.general.getboolean('utf8_encode'): + sub.set_encoding("utf-8") + try: sub.format = (get_format_identifier(os.path.splitext(subtitle.filename)[1]),) except Exception: