diff --git a/main.py b/main.py index eeccdc0..2fe1f9b 100644 --- a/main.py +++ b/main.py @@ -2,8 +2,10 @@ import argparse import asyncio import json import queue +import shutil import threading from collections.abc import Callable +from pathlib import Path from typing import Any import env @@ -64,6 +66,23 @@ def main() -> None: flush_caches() return + def _test_binary(binary: str) -> bool: + if "/" in binary or "\\" in binary: + return Path(binary).exists() + return shutil.which(binary) is not None + + if not _test_binary(env.FFMPEG_PATH): + LOGGER.error( + "ffmpeg is required to crosspost media, but was not found!", env.FFMPEG_PATH + ) + return + if not _test_binary(env.FFPROBE_PATH): + LOGGER.error( + "ffprobe is required to crosspost media, but was not found!", + env.FFPROBE_PATH, + ) + return + if not env.DATA_DIR.exists(): env.DATA_DIR.mkdir(parents=True)