diff options
author | morpheus65535 <[email protected]> | 2023-02-14 12:55:37 -0500 |
---|---|---|
committer | morpheus65535 <[email protected]> | 2023-02-14 12:55:37 -0500 |
commit | 8ac3b0c9b56def6153e3144bec7be0f0abf56f8a (patch) | |
tree | f13baf292fe1acf7ab7d950961368433eacf2aac | |
parent | 839ce384c64caa9767125661b4a51364965a907b (diff) | |
download | bazarr-1.1.5-beta.15.tar.gz bazarr-1.1.5-beta.15.zip |
Fixed chmod not working after custom post-processing.v1.1.5-beta.15
-rw-r--r-- | bazarr/subtitles/processing.py | 3 | ||||
-rw-r--r-- | bazarr/subtitles/upload.py | 3 | ||||
-rw-r--r-- | bazarr/utilities/post_processing.py | 13 |
3 files changed, 17 insertions, 2 deletions
diff --git a/bazarr/subtitles/processing.py b/bazarr/subtitles/processing.py index 37cfced1f..9c0bfceae 100644 --- a/bazarr/subtitles/processing.py +++ b/bazarr/subtitles/processing.py @@ -5,7 +5,7 @@ import logging from app.config import settings from utilities.path_mappings import path_mappings -from utilities.post_processing import pp_replace +from utilities.post_processing import pp_replace, set_chmod from languages.get_languages import alpha2_from_alpha3, alpha2_from_language, alpha3_from_language, language_from_alpha3 from app.database import TableEpisodes, TableMovies from utilities.analytics import track_event @@ -95,6 +95,7 @@ def process_subtitle(subtitle, media_type, audio_language, path, max_score, is_u if not use_pp_threshold or (use_pp_threshold and percent_score < pp_threshold): logging.debug("BAZARR Using post-processing command: {}".format(command)) postprocessing(command, path) + set_chmod(subtitles_path=downloaded_path) else: logging.debug("BAZARR post-processing skipped because subtitles score isn't below this " "threshold value: " + str(pp_threshold) + "%") diff --git a/bazarr/subtitles/upload.py b/bazarr/subtitles/upload.py index 6891261f8..28b60454d 100644 --- a/bazarr/subtitles/upload.py +++ b/bazarr/subtitles/upload.py @@ -13,7 +13,7 @@ from pysubs2.formats import get_format_identifier from languages.get_languages import language_from_alpha3, alpha2_from_alpha3, alpha3_from_alpha2 from app.config import settings, get_array_from from utilities.helper import get_target_folder, force_unicode -from utilities.post_processing import pp_replace +from utilities.post_processing import pp_replace, set_chmod from utilities.path_mappings import path_mappings from radarr.notify import notify_radarr from sonarr.notify import notify_sonarr @@ -152,6 +152,7 @@ def manual_upload_subtitle(path, language, forced, hi, media_type, subtitle, aud uploaded_language_code3, audio_language['name'], audio_language['code2'], audio_language['code3'], 100, "1", "manual", series_id, episode_id) postprocessing(command, path) + set_chmod(subtitles_path=subtitle_path) if media_type == 'series': reversed_path = path_mappings.path_replace_reverse(path) diff --git a/bazarr/utilities/post_processing.py b/bazarr/utilities/post_processing.py index 1017b338d..581071256 100644 --- a/bazarr/utilities/post_processing.py +++ b/bazarr/utilities/post_processing.py @@ -2,6 +2,10 @@ import os import re +import sys +import logging + +from app.config import settings # Wraps the input string within quotes & escapes the string @@ -34,3 +38,12 @@ def pp_replace(pp_command, episode, subtitles, language, language_code2, languag pp_command = re.sub(r'[\'"]?{{series_id}}[\'"]?', _escape(str(series_id)), pp_command) pp_command = re.sub(r'[\'"]?{{episode_id}}[\'"]?', _escape(str(episode_id)), pp_command) return pp_command + + +def set_chmod(subtitles_path): + # apply chmod if required + chmod = int(settings.general.chmod, 8) if not sys.platform.startswith( + 'win') and settings.general.getboolean('chmod_enabled') else None + if chmod: + logging.debug(f"BAZARR setting permission to {chmod} on {subtitles_path} after custom post-processing.") + os.chmod(subtitles_path, chmod) |