k
This commit is contained in:
@@ -16,7 +16,6 @@ import time
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from SYS.logger import log, debug
|
||||
from SYS.rich_display import show_provider_config_panel
|
||||
from .HTTP import HTTPClient
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -1105,9 +1104,8 @@ def unlock_link_cmdlet(result: Any, args: Sequence[str], config: Dict[str, Any])
|
||||
api_key = _get_alldebrid_api_key_from_config(config)
|
||||
|
||||
if not api_key:
|
||||
show_provider_config_panel("alldebrid", ["api_key"])
|
||||
log(
|
||||
"AllDebrid API key not configured (provider.alldebrid.api_key)",
|
||||
"AllDebrid API key not configured. Use .config to set it.",
|
||||
file=sys.stderr
|
||||
)
|
||||
return 1
|
||||
|
||||
@@ -311,13 +311,7 @@ def prepare_magnet(
|
||||
) -> tuple[Optional[AllDebridClient], Optional[int]]:
|
||||
api_key = _get_debrid_api_key(config or {})
|
||||
if not api_key:
|
||||
try:
|
||||
from SYS.rich_display import show_provider_config_panel
|
||||
|
||||
show_provider_config_panel("alldebrid", ["api_key"])
|
||||
except Exception:
|
||||
pass
|
||||
log("AllDebrid API key not configured (provider.alldebrid.api_key)", file=sys.stderr)
|
||||
log("AllDebrid API key not configured. Use .config to set it.", file=sys.stderr)
|
||||
return None, None
|
||||
|
||||
try:
|
||||
|
||||
@@ -1187,18 +1187,9 @@ class OpenLibrary(Provider):
|
||||
email, password = self._credential_archive(self.config or {})
|
||||
if not email or not password:
|
||||
log(
|
||||
"[openlibrary] Archive credentials missing; cannot borrow",
|
||||
"[openlibrary] Archive credentials missing; cannot borrow. Use .config to set them.",
|
||||
file=sys.stderr
|
||||
)
|
||||
try:
|
||||
from SYS.rich_display import show_provider_config_panel
|
||||
|
||||
show_provider_config_panel(
|
||||
"openlibrary",
|
||||
keys=self.required_config_keys(),
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
lendable = True
|
||||
|
||||
@@ -81,27 +81,7 @@ def show_provider_config_panel(
|
||||
config_hint: str = "config.conf"
|
||||
) -> None:
|
||||
"""Show a Rich panel explaining how to configure a provider."""
|
||||
|
||||
normalized = str(provider_name or "").strip() or "provider"
|
||||
pre = Text("Add this to your config", style="bold")
|
||||
footer = Text(
|
||||
f"Place this block in {config_hint} or config.d/*.conf",
|
||||
style="dim"
|
||||
)
|
||||
body = Text()
|
||||
body.append(f"[provider={normalized}]\n", style="bold cyan")
|
||||
for key in keys or []:
|
||||
body.append(f'{key}=""\n', style="yellow")
|
||||
|
||||
stderr_console().print(pre)
|
||||
stderr_console().print(
|
||||
Panel(
|
||||
body,
|
||||
title=f"{normalized} configuration",
|
||||
expand=False
|
||||
)
|
||||
)
|
||||
stderr_console().print(footer)
|
||||
pass
|
||||
|
||||
|
||||
def show_store_config_panel(
|
||||
@@ -111,25 +91,5 @@ def show_store_config_panel(
|
||||
config_hint: str = "config.conf"
|
||||
) -> None:
|
||||
"""Show a Rich panel explaining how to configure a storage backend."""
|
||||
|
||||
normalized = str(store_type or "").strip().lower() or "store"
|
||||
pre = Text("Add this to your config", style="bold")
|
||||
footer = Text(
|
||||
f"Place this block in {config_hint} or config.d/*.conf",
|
||||
style="dim"
|
||||
)
|
||||
body = Text()
|
||||
body.append(f"[store={normalized}]\n", style="bold cyan")
|
||||
for key in keys or []:
|
||||
body.append(f'{key}=""\n', style="yellow")
|
||||
|
||||
stderr_console().print(pre)
|
||||
stderr_console().print(
|
||||
Panel(
|
||||
body,
|
||||
title=f"{normalized} storage configuration",
|
||||
expand=False
|
||||
)
|
||||
)
|
||||
stderr_console().print(footer)
|
||||
pass
|
||||
|
||||
|
||||
@@ -555,34 +555,7 @@ class search_file(Cmdlet):
|
||||
worker_id = str(uuid.uuid4())
|
||||
library_root = get_local_storage_path(config or {})
|
||||
if not library_root:
|
||||
log("No library root configured", file=sys.stderr)
|
||||
log("", file=sys.stderr)
|
||||
|
||||
# Show config panel for FolderStore
|
||||
try:
|
||||
from SYS.rich_display import show_store_config_panel
|
||||
show_store_config_panel("folder", ["NAME", "PATH"])
|
||||
log("", file=sys.stderr)
|
||||
except Exception:
|
||||
log("Example config for FolderStore:", file=sys.stderr)
|
||||
log("[store=folder]", file=sys.stderr)
|
||||
log('NAME="default"', file=sys.stderr)
|
||||
log('PATH="/path/to/library"', file=sys.stderr)
|
||||
log("", file=sys.stderr)
|
||||
|
||||
# Show config panel for HydrusNetworkStore
|
||||
try:
|
||||
from SYS.rich_display import show_store_config_panel
|
||||
show_store_config_panel("hydrusnetwork", ["NAME", "API", "URL"])
|
||||
log("", file=sys.stderr)
|
||||
except Exception:
|
||||
log("Example config for HydrusNetworkStore:", file=sys.stderr)
|
||||
log("[store=hydrusnetwork]", file=sys.stderr)
|
||||
log('NAME="default"', file=sys.stderr)
|
||||
log('API="your-api-key"', file=sys.stderr)
|
||||
log('URL="http://localhost:45869"', file=sys.stderr)
|
||||
log("", file=sys.stderr)
|
||||
|
||||
log("No library root configured. Use the .config command to set up storage.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
# Use context manager to ensure database is always closed
|
||||
|
||||
@@ -103,7 +103,7 @@ def _run(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
|
||||
library_root = get_local_storage_path(config or {})
|
||||
if not library_root:
|
||||
log("No library root configured", file=sys.stderr)
|
||||
log("No library root configured. Use the .config command to set up storage.", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user