This commit is contained in:
nose
2025-12-13 00:18:30 -08:00
parent 85750247cc
commit 30eb628aa3
18 changed files with 1056 additions and 407 deletions

79
CLI.py
View File

@@ -200,7 +200,7 @@ CLI_ROOT = Path(__file__).resolve().parent
def _load_cli_config() -> Dict[str, Any]:
"""Load config.json relative to the CLI script location."""
"""Load config.conf relative to the CLI script location."""
try:
return deepcopy(load_config(config_dir=CLI_ROOT))
except Exception:
@@ -697,7 +697,7 @@ def _create_cmdlet_cli():
# Initialize cookies check for yt-dlp
from hydrus_health_check import initialize_cookies_check
initialize_cookies_check()
initialize_cookies_check(config, emit_debug=False)
# Initialize debug logging if enabled
if config:
@@ -788,6 +788,22 @@ def _create_cmdlet_cli():
if detail:
row.add_column("Detail", detail)
def _has_store_subtype(cfg: dict, subtype: str) -> bool:
store_cfg = cfg.get("store")
if not isinstance(store_cfg, dict):
return False
bucket = store_cfg.get(subtype)
if not isinstance(bucket, dict):
return False
return any(isinstance(v, dict) and bool(v) for v in bucket.values())
def _has_provider(cfg: dict, name: str) -> bool:
provider_cfg = cfg.get("provider")
if not isinstance(provider_cfg, dict):
return False
block = provider_cfg.get(str(name).strip().lower())
return isinstance(block, dict) and bool(block)
# Load config and initialize debug logging
config = {}
try:
@@ -846,37 +862,36 @@ def _create_cmdlet_cli():
_run_check("MPV", lambda: initialize_mpv_health_check(emit_debug=False))
if config:
_run_check("Hydrus", lambda: initialize_hydrus_health_check(config, emit_debug=False))
# Hydrus instances - add individual rows for each instance
from hydrus_health_check import _SERVICE_STATE
for instance_name, instance_info in _SERVICE_STATE.get("hydrusnetwork_stores", {}).items():
status = "ENABLED" if instance_info.get("ok") else "DISABLED"
_add_startup_check(f" {instance_name}", status, f"{instance_info.get('url')} - {instance_info.get('detail')}")
_run_check("Matrix", lambda: initialize_matrix_health_check(config, emit_debug=False))
# Folder stores - add individual rows for each store
ok, detail = initialize_local_library_scan(config, emit_debug=False)
if ok or detail != "No folder stores configured":
# Add individual store rows
from hydrus_health_check import _SERVICE_STATE
for store_name, store_info in _SERVICE_STATE.get("folder_stores", {}).items():
status = "SCANNED" if store_info.get("ok") else "ERROR"
_add_startup_check(f" {store_name}", status, f"{store_info.get('path')} - {store_info.get('detail')}")
if not _SERVICE_STATE.get("folder_stores"):
_add_startup_check("Folder Stores", "SCANNED", detail)
else:
_add_startup_check("Folder Stores", "SKIPPED", detail)
_run_check("Debrid", lambda: initialize_debrid_health_check(config, emit_debug=False))
else:
_add_startup_check("Hydrus", "SKIPPED", "No config loaded")
_add_startup_check("Matrix", "SKIPPED", "No config loaded")
_add_startup_check("Folder Stores", "SKIPPED", "No config loaded")
_add_startup_check("Debrid", "SKIPPED", "No config loaded")
# Only show checks that are configured in config.conf
if _has_store_subtype(config, "hydrusnetwork"):
_run_check("Hydrus", lambda: initialize_hydrus_health_check(config, emit_debug=False))
_run_check("Cookies", lambda: initialize_cookies_check(emit_debug=False))
# Hydrus instances - add individual rows for each configured instance
from hydrus_health_check import _SERVICE_STATE
for instance_name, instance_info in _SERVICE_STATE.get("hydrusnetwork_stores", {}).items():
status = "ENABLED" if instance_info.get("ok") else "DISABLED"
_add_startup_check(f" {instance_name}", status, f"{instance_info.get('url')} - {instance_info.get('detail')}")
if _has_provider(config, "matrix"):
_run_check("Matrix", lambda: initialize_matrix_health_check(config, emit_debug=False))
if _has_store_subtype(config, "folder"):
# Folder stores - add individual rows for each configured store
ok, detail = initialize_local_library_scan(config, emit_debug=False)
if ok or detail != "No folder stores configured":
from hydrus_health_check import _SERVICE_STATE
for store_name, store_info in _SERVICE_STATE.get("folder_stores", {}).items():
status = "SCANNED" if store_info.get("ok") else "ERROR"
_add_startup_check(f" {store_name}", status, f"{store_info.get('path')} - {store_info.get('detail')}")
if not _SERVICE_STATE.get("folder_stores"):
_add_startup_check("Folder Stores", "SCANNED", detail)
else:
_add_startup_check("Folder Stores", "SKIPPED", detail)
if _has_store_subtype(config, "debrid"):
_run_check("Debrid", lambda: initialize_debrid_health_check(config, emit_debug=False))
_run_check("Cookies", lambda: initialize_cookies_check(config, emit_debug=False))
if startup_table is not None and startup_table.rows:
print()