Skip to content

Commit

Permalink
[BACKEND] Add /usr/local/bin/ffmpeg as possible default location (#1056)
Browse files Browse the repository at this point in the history
For better cross-platform support
  • Loading branch information
jmbannon authored Sep 20, 2024
1 parent 10cb82a commit 6510fd0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/ytdl_sub/config/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

from ytdl_sub.utils.system import IS_WINDOWS


def _existing_path(*paths: str) -> str:
"""
Tries to search multiple paths for a file, returns a
path if it exists. If none are valid files, returns
the first one
"""
for path in paths:
if os.path.isfile(path):
return path
return paths[0]


if IS_WINDOWS:
DEFAULT_LOCK_DIRECTORY = "" # Not supported in Windows
DEFAULT_FFMPEG_PATH = ".\\ffmpeg.exe"
Expand All @@ -10,8 +23,8 @@
MAX_FILE_NAME_BYTES = 255
else:
DEFAULT_LOCK_DIRECTORY = "/tmp"
DEFAULT_FFMPEG_PATH = "/usr/bin/ffmpeg"
DEFAULT_FFPROBE_PATH = "/usr/bin/ffprobe"
DEFAULT_FFMPEG_PATH = _existing_path("/usr/bin/ffmpeg", "/usr/local/bin/ffmpeg")
DEFAULT_FFPROBE_PATH = _existing_path("/usr/bin/ffprobe", "/usr/local/bin/ffmpeg")

MAX_FILE_NAME_BYTES = os.pathconf("/", "PC_NAME_MAX")

Expand Down

0 comments on commit 6510fd0

Please sign in to comment.