Skip to content

Commit bf276e3

Browse files
authored
Merge pull request #15 from FlorianEagox/main
Adding the ability to specify a desired path
2 parents bc6fdd6 + 7188399 commit bf276e3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

static_ffmpeg/_add_paths.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def _has(name: str) -> bool:
1313
return shutil.which(name) is not None
1414

1515

16-
def add_paths(weak=False) -> bool:
16+
def add_paths(weak=False, download_dir=None) -> bool:
1717
"""Add the ffmpeg executable to the path"""
1818
if weak:
1919
has_ffmpeg = _has("ffmpeg") is not None
2020
has_ffprobe = _has("ffprobe") is not None
2121
if has_ffmpeg and has_ffprobe:
2222
return False
23-
ffmpeg, _ = get_or_fetch_platform_executables_else_raise()
23+
ffmpeg, _ = get_or_fetch_platform_executables_else_raise(download_dir=download_dir)
2424
ffmpeg_path = os.path.dirname(ffmpeg)
2525
if ffmpeg_path not in os.environ["PATH"]:
2626
os.environ["PATH"] = os.pathsep.join([ffmpeg_path, os.environ["PATH"]])

static_ffmpeg/run.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,28 +72,32 @@ def download_file(url, local_path):
7272

7373
def get_or_fetch_platform_executables_else_raise(
7474
fix_permissions=True,
75+
download_dir=None
7576
) -> Tuple[str, str]:
7677
"""Either get the executable or raise an error"""
7778
lock = FileLock(LOCK_FILE, timeout=TIMEOUT) # pylint: disable=E0110
7879
try:
7980
with lock.acquire():
8081
return _get_or_fetch_platform_executables_else_raise_no_lock(
81-
fix_permissions=fix_permissions
82+
fix_permissions=fix_permissions,
83+
download_dir=download_dir
8284
)
8385
except Timeout:
8486
sys.stderr.write(
8587
f"{__file__}: Warning, could not acquire lock at {LOCK_FILE}\n"
8688
)
8789
return _get_or_fetch_platform_executables_else_raise_no_lock(
88-
fix_permissions=fix_permissions
90+
fix_permissions=fix_permissions,
91+
download_dir=download_dir
8992
)
9093

9194

9295
def _get_or_fetch_platform_executables_else_raise_no_lock(
9396
fix_permissions=True,
97+
download_dir=None
9498
) -> Tuple[str, str]:
9599
"""Either get the executable or raise an error, internal api"""
96-
exe_dir = get_platform_dir()
100+
exe_dir = download_dir if download_dir else get_platform_dir()
97101
installed_crumb = os.path.join(exe_dir, "installed.crumb")
98102
if not os.path.exists(installed_crumb):
99103
# All zip files store their platform executables in a folder

0 commit comments

Comments
 (0)