diff --git a/CHANGELOG.md b/CHANGELOG.md index 832b2c7f..8ce7b877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,7 +65,7 @@ Click up arrow to go back to TOC. - Change all text file input decoding into "utf-8". - Change the default style selection in subtitles translation. - Change the loglevel in ffmpeg commands into `-loglevel error`. -- Change DEFAULT_MIN_REGION_SIZE to 0.5 +- Change DEFAULT_MIN_REGION_SIZE to 0.5. #### Fixed(Unreleased) @@ -73,6 +73,7 @@ Click up arrow to go back to TOC. - Fix delete_chars issue when using `-of full-src`. - Fix os.remove() PermissionError in api_xfyun.py. - Fix DEFAULT_AUDIO_PRCS_CMDS and DEFAULT_CHECK_CMD. +- Fix the issue with path checking in dependency finding. #### Removed(Unreleased) diff --git a/autosub/constants.py b/autosub/constants.py index 3cf6c847..278f695d 100644 --- a/autosub/constants.py +++ b/autosub/constants.py @@ -394,33 +394,39 @@ def which_exe(program_path): def get_cmd(program_name): """ - Return the executable name. "" returned when no executable exists. + Return the path for a given executable. + "" returned when no executable exists. """ - command = which_exe(program_name) - if command: - return command - - command = which_exe(program_name + ".exe") - if command: - return command + if not sys.platform.startswith('win'): + command = which_exe(program_name) + if command: + return command + else: + command = which_exe(program_name + ".exe") + if command: + return command return "" -if 'FFMPEG_PATH' in os.environ: - FFMPEG_CMD = os.environ['FFMPEG_PATH'] -else: - FFMPEG_CMD = get_cmd("ffmpeg") +def get_cmd_from_env(program_name, env_name): + """ + Return the path or the value of environment variable + for a given executable. + """ + if env_name in os.environ: + if is_exe(os.environ[env_name]): + return os.environ[env_name] + program_name = os.path.join(os.environ[env_name], program_name) + if is_exe(program_name): + return program_name + return program_name + ".exe" + return get_cmd(program_name) -if 'FFPROBE_PATH' in os.environ: - FFPROBE_CMD = os.environ['FFPROBE_PATH'] -else: - FFPROBE_CMD = get_cmd("ffprobe") -if 'FFMPEG_NORMALIZE_PATH' in os.environ: - FFMPEG_NORMALIZE_CMD = os.environ['FFMPEG_NORMALIZE_PATH'] -else: - FFMPEG_NORMALIZE_CMD = get_cmd("ffmpeg-normalize") +FFMPEG_CMD = get_cmd_from_env("ffmpeg", "FFMPEG_PATH") +FFPROBE_CMD = get_cmd_from_env("ffprobe", "FFPROBE_PATH") +FFMPEG_NORMALIZE_CMD = get_cmd_from_env("ffmpeg-normalize", "FFMPEG_NORMALIZE_PATH") DEFAULT_AUDIO_PRCS_CMDS = [ FFMPEG_CMD + " -hide_banner -i \"{in_}\" -vn -af \"asplit[a],aphasemeter=video=0,\ diff --git a/docs/CHANGELOG.zh-Hans.md b/docs/CHANGELOG.zh-Hans.md index 762cd06b..fab0b5b8 100644 --- a/docs/CHANGELOG.zh-Hans.md +++ b/docs/CHANGELOG.zh-Hans.md @@ -71,6 +71,7 @@ - 修复delete_chars问题当使用`-of full-src`时。 - 修复api_xfyun.py中的os.remove()文件占用问题。 - 修复DEFAULT_AUDIO_PRCS_CMDS和DEFAULT_CHECK_CMD。 +- 修复依赖查找中,路径检查的问题。 #### 删除(未发布)