diff --git a/src/ruvsarpur.py b/src/ruvsarpur.py index 696179f..1ed0c90 100644 --- a/src/ruvsarpur.py +++ b/src/ruvsarpur.py @@ -58,6 +58,8 @@ from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) +import utilities + # Lambdas as shorthands for printing various types of data # See https://pypi.python.org/pypi/termcolor for more info color_title = lambda x: colored(x, 'cyan', 'on_grey') @@ -897,6 +899,12 @@ def findffmpeg(path_to_ffmpeg_install=None, working_dir=None): if os.path.isfile(bin_dist): return str(Path(bin_dist).resolve()) + # Attempt to find ffmpeg in the environment + try: + return utilities.get_ffmpeg_location() + except Exception: + pass # Ignoring the exception + # Throw an error raise ValueError('Could not locate FFMPEG install, please use the --ffmpeg switch to specify the path to the ffmpeg executable on your system.') diff --git a/src/utilities.py b/src/utilities.py new file mode 100644 index 0000000..018c7b6 --- /dev/null +++ b/src/utilities.py @@ -0,0 +1,18 @@ +import shutil + + +def get_ffmpeg_location(): + """ + Locate the ffmpeg executable in the system's PATH. + + Returns: + str: The path to the ffmpeg executable. + + Raises: + FileNotFoundError: If ffmpeg is not found in the PATH. + """ + ffmpeg_path = shutil.which("ffmpeg") + if ffmpeg_path: + return ffmpeg_path + else: + raise FileNotFoundError("ffmpeg not found in PATH")