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:
+11
-5
@@ -82,16 +82,22 @@ 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):
|
||||||
|
# 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)
|
path = Path(path_str)
|
||||||
|
|
||||||
# If relative, resolve relative to the config file location
|
|
||||||
if not path.is_absolute():
|
if not path.is_absolute():
|
||||||
path = (self.config_path.parent / path).resolve()
|
path = (self.config_path.parent / path).resolve()
|
||||||
|
|
||||||
# Check direct file existence OR system PATH
|
|
||||||
if path.is_file() or shutil.which(str(path)):
|
if path.is_file() or shutil.which(str(path)):
|
||||||
return
|
return
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"{WARN}[ERROR] {name} not found.\n"
|
f"{WARN}[ERROR] {name} not found.\n"
|
||||||
f" Configured path: '{path_str}'\n"
|
f" Configured path: '{path_str}'\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user