1
0
mirror of https://github.com/darkzoul5/YoutubePlaylistSync.git synced 2026-07-03 12:34:00 +03:00

Improve logic in ConfigLoader to handle binaries in PATH

This commit is contained in:
2025-10-15 19:03:09 +03:00
parent ed8398f28c
commit 66758edb4b
+11 -5
View File
@@ -82,16 +82,22 @@ class ConfigLoader:
json.dump(self.DEFAULT_CONFIG, f, indent=2)
def _check_binary(self, path_str, name):
# If path_str looks like a system binary (no slashes), check PATH only
if os.sep not in path_str and '/' not in path_str:
if shutil.which(path_str):
return
print(
f"{WARN}[ERROR] {name} not found in system PATH.\n"
f" Configured path: '{path_str}'\n"
f"Please install or correct the path in yt-playlist-config.json ."
)
sys.exit(1)
else:
path = Path(path_str)
# If relative, resolve relative to the config file location
if not path.is_absolute():
path = (self.config_path.parent / path).resolve()
# Check direct file existence OR system PATH
if path.is_file() or shutil.which(str(path)):
return
print(
f"{WARN}[ERROR] {name} not found.\n"
f" Configured path: '{path_str}'\n"