get_ffmpeg_tool_path moved to ffmpeg utils

This commit is contained in:
iLLiCiTiT 2020-11-18 19:33:24 +01:00
parent 9a04ace92b
commit 4e0ae38a12
3 changed files with 30 additions and 27 deletions

View file

@ -5,28 +5,6 @@ import logging
log = logging.getLogger(__name__)
def get_ffmpeg_tool_path(tool="ffmpeg"):
"""Find path to ffmpeg tool in FFMPEG_PATH paths.
Function looks for tool in paths set in FFMPEG_PATH environment. If tool
exists then returns it's full path.
Args:
tool (string): tool name
Returns:
(str): tool name itself when tool path was not found. (FFmpeg path
may be set in PATH environment variable)
"""
dir_paths = get_paths_from_environ("FFMPEG_PATH")
for dir_path in dir_paths:
for file_name in os.listdir(dir_path):
base, _ext = os.path.splitext(file_name)
if base.lower() == tool.lower():
return os.path.join(dir_path, tool)
return tool
def _rreplace(s, a, b, n=1):
"""Replace a with b in string s from right side n times."""
return b.join(s.rsplit(a, n))