Fixed chmod not working after custom post-processing.

This commit is contained in:
morpheus65535 2023-02-14 12:55:37 -05:00
parent 839ce384c6
commit 8ac3b0c9b5
3 changed files with 17 additions and 2 deletions

View File

@ -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) + "%")

View File

@ -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)

View File

@ -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)