Skip to content

Commit 0c65e62

Browse files
authored
Merge pull request #38 from bransoned/feature/25-combine-dependency-functions
Feature/25 combine dependency functions
2 parents 640bce7 + 6695285 commit 0c65e62

File tree

3 files changed

+10
-41
lines changed

3 files changed

+10
-41
lines changed

src/dependencies.py

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import sys
1+
from .exceptions import *
22
from pathlib import Path
33
import shutil
4-
from .exceptions import *
4+
import sys
55

66
# =========================================================================== #
77

88
"""
9-
Find exiftool executable
9+
Find dependency executable
1010
1111
Returns:
12-
Path to exiftool
12+
Path to dependency
1313
1414
Raises:
15-
DependencyError: If exiftool cannot be found
15+
DependencyError: If dependency cannot be found
1616
"""
17-
def find_exiftool() -> str:
17+
def find_dependency(dependency_str: str) -> str:
1818

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

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

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

3838
# =========================================================================== #
3939

40-
"""
41-
Find ffmpeg executable.
42-
43-
Returns:
44-
Path to ffmpeg
45-
46-
Raises:
47-
DependencyError: If ffmpeg cannot be found
48-
"""
49-
def find_ffmpeg() -> str:
50-
51-
exe_name = "ffmpeg.exe" if sys.platform.startswith("win") else "ffmpeg"
52-
53-
# If bundle
54-
if getattr(sys, "frozen", False):
55-
base = Path(sys._MEIPASS)
56-
bundled = base / "bin" / exe_name
57-
if bundled.exists():
58-
return str(bundled)
59-
60-
# Try system PATH
61-
system_path = shutil.which(exe_name)
62-
if system_path:
63-
return system_path
64-
65-
raise DependencyError(
66-
"FFMpeg not found. Please install ffmpeg or use the provided bundled executable."
67-
"For further installation instructions, reference the README."
68-
)
69-
70-
# =========================================================================== #

src/media_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def merge_mp4_with_overlay(mp4_path: Path, png_path: Path) -> Path:
183183

184184
# Find ffmpeg dependency
185185
try:
186-
ffmpeg_path = find_ffmpeg()
186+
ffmpeg_path = find_dependency("ffmpeg")
187187
except DependencyError:
188188
raise # Re-raise to be handled by caller
189189

src/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def write_exif(file_path: Path, date_time_str: str, lat: str, lon: str) -> None:
9090
ext = 'jpg'
9191

9292
try:
93-
exiftool_path = find_exiftool()
93+
exiftool_path = find_dependency("exiftool")
9494
except DependencyError:
9595
raise
9696

0 commit comments

Comments
 (0)