Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 8 additions & 39 deletions src/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import sys
from .exceptions import *
from pathlib import Path
import shutil
from .exceptions import *
import sys

# =========================================================================== #

"""
Find exiftool executable
Find dependency executable

Returns:
Path to exiftool
Path to dependency

Raises:
DependencyError: If exiftool cannot be found
DependencyError: If dependency cannot be found
"""
def find_exiftool() -> str:
def find_dependency(dependency_str: str) -> str:

exe_name = "exiftool.exe" if sys.platform.startswith("win") else "exiftool"
exe_name = f"{dependency_str}.exe" if sys.platform.startswith("win") else f"{dependency_str}"

# If bundle
if getattr(sys, "frozen", False):
Expand All @@ -31,40 +31,9 @@ def find_exiftool() -> str:
return system_path

raise DependencyError(
"Exiftool not found. Please install exiftool or use the provided bundled executable."
f"{depency_str} not found. Please install {dependency_str} or use the provided bundled executable."
"For further installation instructions, reference the README."
)

# =========================================================================== #

"""
Find ffmpeg executable.

Returns:
Path to ffmpeg

Raises:
DependencyError: If ffmpeg cannot be found
"""
def find_ffmpeg() -> str:

exe_name = "ffmpeg.exe" if sys.platform.startswith("win") else "ffmpeg"

# If bundle
if getattr(sys, "frozen", False):
base = Path(sys._MEIPASS)
bundled = base / "bin" / exe_name
if bundled.exists():
return str(bundled)

# Try system PATH
system_path = shutil.which(exe_name)
if system_path:
return system_path

raise DependencyError(
"FFMpeg not found. Please install ffmpeg or use the provided bundled executable."
"For further installation instructions, reference the README."
)

# =========================================================================== #
2 changes: 1 addition & 1 deletion src/media_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def merge_mp4_with_overlay(mp4_path: Path, png_path: Path) -> Path:

# Find ffmpeg dependency
try:
ffmpeg_path = find_ffmpeg()
ffmpeg_path = find_dependency("ffmpeg")
except DependencyError:
raise # Re-raise to be handled by caller

Expand Down
2 changes: 1 addition & 1 deletion src/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def write_exif(file_path: Path, date_time_str: str, lat: str, lon: str) -> None:
ext = 'jpg'

try:
exiftool_path = find_exiftool()
exiftool_path = find_dependency("exiftool")
except DependencyError:
raise

Expand Down