From 7d8b9d812a1ab4b2fd9e8b547863c8d56183028d Mon Sep 17 00:00:00 2001 From: Halali Date: Sun, 14 Apr 2019 09:29:48 +0200 Subject: [PATCH] Fix issue with show subfolder in subtitles path --- bazarr/list_subtitles.py | 10 +++++----- bazarr/main.py | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bazarr/list_subtitles.py b/bazarr/list_subtitles.py index a70607069..4bf693734 100644 --- a/bazarr/list_subtitles.py +++ b/bazarr/list_subtitles.py @@ -139,7 +139,7 @@ def store_subtitles_movie(file): else: logging.debug("BAZARR This file isn't an .mkv file.") - dest_folder = get_subtitle_destination_folder() + dest_folder = get_subtitle_destination_folder() or '' subliminal_patch.core.CUSTOM_PATHS = [dest_folder] if dest_folder else [] brazilian_portuguese = [".pt-br", ".pob", "pb"] try: @@ -153,15 +153,15 @@ def store_subtitles_movie(file): if str(os.path.splitext(subtitle)[0]).lower().endswith(tuple(brazilian_portuguese)) is True: logging.debug("BAZARR external subtitles detected: " + "pb") actual_subtitles.append( - [str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))]) + [str("pb"), path_replace_reverse_movie(os.path.join(os.path.dirname(file), dest_folder, subtitle))]) elif str(language) != 'und': logging.debug("BAZARR external subtitles detected: " + str(language)) actual_subtitles.append( - [str(language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), subtitle))]) + [str(language), path_replace_reverse_movie(os.path.join(os.path.dirname(file), dest_folder, subtitle))]) else: if os.path.splitext(subtitle)[1] != ".sub": logging.debug("BAZARR falling back to file content analysis to detect language.") - with open(path_replace_movie(os.path.join(os.path.dirname(file), subtitle)), 'r') as f: + with open(path_replace_movie(os.path.join(os.path.dirname(file), dest_folder, subtitle)), 'r') as f: text = list(islice(f, 100)) text = ' '.join(text) encoding = UnicodeDammit(text) @@ -179,7 +179,7 @@ def store_subtitles_movie(file): "BAZARR external subtitles detected and analysis guessed this language: " + str( detected_language)) actual_subtitles.append([str(detected_language), path_replace_reverse_movie( - os.path.join(os.path.dirname(file), subtitle))]) + os.path.join(os.path.dirname(file), dest_folder, subtitle))]) conn_db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30) c_db = conn_db.cursor() diff --git a/bazarr/main.py b/bazarr/main.py index a8c1e8e26..4ac9acf5e 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -1307,7 +1307,10 @@ def save_settings(): settings.general.path_mappings_movie = text_type(settings_general_pathmapping_movie) settings.general.page_size = text_type(settings_page_size) settings.general.subfolder = text_type(settings_subfolder) - settings.general.subfolder_custom = text_type(settings_subfolder_custom) + if settings.general.subfolder == 'current': + settings.general.subfolder_custom = '' + else: + settings.general.subfolder_custom = text_type(settings_subfolder_custom) settings.general.upgrade_subs = text_type(settings_upgrade_subs) settings.general.days_to_upgrade_subs = text_type(settings_days_to_upgrade_subs) settings.general.upgrade_manual = text_type(settings_upgrade_manual)