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
+23 -17
View File
@@ -82,23 +82,29 @@ class ConfigLoader:
json.dump(self.DEFAULT_CONFIG, f, indent=2) json.dump(self.DEFAULT_CONFIG, f, indent=2)
def _check_binary(self, path_str, name): def _check_binary(self, path_str, name):
path = Path(path_str) # 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 relative, resolve relative to the config file location if shutil.which(path_str):
if not path.is_absolute(): return
path = (self.config_path.parent / path).resolve() print(
f"{WARN}[ERROR] {name} not found in system PATH.\n"
# Check direct file existence OR system PATH f" Configured path: '{path_str}'\n"
if path.is_file() or shutil.which(str(path)): f"Please install or correct the path in yt-playlist-config.json ."
return )
sys.exit(1)
print( else:
f"{WARN}[ERROR] {name} not found.\n" path = Path(path_str)
f" Configured path: '{path_str}'\n" if not path.is_absolute():
f" Resolved absolute path: '{path}'\n" path = (self.config_path.parent / path).resolve()
f"Please correct the yt-playlist-config.json path." if path.is_file() or shutil.which(str(path)):
) return
sys.exit(1) print(
f"{WARN}[ERROR] {name} not found.\n"
f" Configured path: '{path_str}'\n"
f" Resolved absolute path: '{path}'\n"
f"Please correct the yt-playlist-config.json path."
)
sys.exit(1)
@property @property
def playlists(self): def playlists(self):