mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-25 17:17:12 +00:00
no log: some pep8 fixes
This commit is contained in:
parent
81e13e1eac
commit
0d12bcb39e
3 changed files with 17 additions and 14 deletions
|
@ -81,11 +81,9 @@ def process_subtitle(subtitle, media_type, audio_language, path, max_score, is_u
|
|||
radarr_id=movie_metadata['radarrId'])
|
||||
|
||||
if use_postprocessing is True:
|
||||
command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language,
|
||||
downloaded_language_code2, downloaded_language_code3, audio_language,
|
||||
audio_language_code2, audio_language_code3, subtitle.language.forced,
|
||||
percent_score, subtitle_id, downloaded_provider, series_id, episode_id,
|
||||
subtitle.language.hi)
|
||||
command = pp_replace(postprocessing_cmd, path, downloaded_path, downloaded_language, downloaded_language_code2,
|
||||
downloaded_language_code3, audio_language, audio_language_code2, audio_language_code3,
|
||||
percent_score, subtitle_id, downloaded_provider, series_id, episode_id)
|
||||
|
||||
if media_type == 'series':
|
||||
use_pp_threshold = settings.general.getboolean('use_postprocessing_threshold')
|
||||
|
|
|
@ -150,10 +150,9 @@ def manual_upload_subtitle(path, language, forced, hi, title, scene_name, media_
|
|||
percent_score=100, radarr_id=movie_metadata['radarrId'], forced=forced)
|
||||
|
||||
if use_postprocessing:
|
||||
command = pp_replace(postprocessing_cmd, path, subtitle_path, uploaded_language,
|
||||
uploaded_language_code2, uploaded_language_code3, audio_language,
|
||||
audio_language_code2, audio_language_code3, forced, 100, "1", "manual", series_id,
|
||||
episode_id, hi=hi)
|
||||
command = pp_replace(postprocessing_cmd, path, subtitle_path, uploaded_language, uploaded_language_code2,
|
||||
uploaded_language_code3, audio_language, audio_language_code2, audio_language_code3, 100,
|
||||
"1", "manual", series_id, episode_id)
|
||||
postprocessing(command, path)
|
||||
|
||||
if media_type == 'series':
|
||||
|
|
|
@ -3,22 +3,28 @@
|
|||
import os
|
||||
import re
|
||||
|
||||
|
||||
# Wraps the input string within quotes & escapes the string
|
||||
def _escape(in_str):
|
||||
raw_map = {8:r'\\b', 7:r'\\a', 12:r'\\f', 10:r'\\n', 13:r'\\r', 9:r'\\t', 11:r'\\v', 34:r'\"', 92:r'\\'}
|
||||
raw_map = {8: r'\\b', 7: r'\\a', 12: r'\\f', 10: r'\\n', 13: r'\\r', 9: r'\\t', 11: r'\\v', 34: r'\"', 92: r'\\'}
|
||||
raw_str = r''.join(raw_map.get(ord(i), i) for i in in_str)
|
||||
return f"\"{raw_str}\""
|
||||
|
||||
def pp_replace(pp_command, episode, subtitles, language, language_code2, language_code3, episode_language, episode_language_code2, episode_language_code3, forced, score, subtitle_id, provider, series_id, episode_id, hi):
|
||||
|
||||
def pp_replace(pp_command, episode, subtitles, language, language_code2, language_code3, episode_language,
|
||||
episode_language_code2, episode_language_code3, score, subtitle_id, provider, series_id, episode_id):
|
||||
pp_command = re.sub(r'[\'"]?{{directory}}[\'"]?', _escape(os.path.dirname(episode)), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{episode}}[\'"]?', _escape(episode), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{episode_name}}[\'"]?', _escape(os.path.splitext(os.path.basename(episode))[0]), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{episode_name}}[\'"]?', _escape(os.path.splitext(os.path.basename(episode))[0]),
|
||||
pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles}}[\'"]?', _escape(str(subtitles)), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles_language}}[\'"]?', _escape(str(language)), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles_language_code2}}[\'"]?', _escape(str(language_code2)), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles_language_code3}}[\'"]?', _escape(str(language_code3)), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles_language_code2_dot}}[\'"]?', _escape(str(language_code2).replace(':', '.')), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles_language_code3_dot}}[\'"]?', _escape(str(language_code3).replace(':', '.')), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles_language_code2_dot}}[\'"]?',
|
||||
_escape(str(language_code2).replace(':', '.')), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{subtitles_language_code3_dot}}[\'"]?',
|
||||
_escape(str(language_code3).replace(':', '.')), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{episode_language}}[\'"]?', _escape(str(episode_language)), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{episode_language_code2}}[\'"]?', _escape(str(episode_language_code2)), pp_command)
|
||||
pp_command = re.sub(r'[\'"]?{{episode_language_code3}}[\'"]?', _escape(str(episode_language_code3)), pp_command)
|
||||
|
|
Loading…
Reference in a new issue