Add anipy-cli download fallback

Add an optional config toggle that retries failed ani-cli downloads with anipy-cli, expose fallback runtime status in the config page, and update release docs and tests for the new behavior.
This commit is contained in:
Dymas
2026-07-09 14:11:40 +02:00
parent 332ec670fc
commit d8ed64bd64
8 changed files with 319 additions and 61 deletions
+28 -2
View File
@@ -21,6 +21,7 @@ from urllib.parse import parse_qs, unquote, urlencode, urlparse, urlunparse
from app_support import (
ANI_CLI,
ANIPY_CLI,
APP_NAME,
CHANGELOG_FILE,
CLIENT_DISCONNECT_ERRORS,
@@ -32,6 +33,7 @@ from app_support import (
debug_enabled,
debug_log,
load_project_text_file,
cli_executable_exists,
normalize_config,
path_is_within_roots,
remote_access_allowed,
@@ -87,7 +89,8 @@ def build_handler_class(context):
def dependency_status():
checks = ["curl", "sed", "grep", "openssl", "fzf", "aria2c", "ffmpeg", "yt-dlp"]
result = {name: bool(shutil.which(name)) for name in checks}
result["ani-cli"] = bool(shutil.which(ANI_CLI) or (Path(ANI_CLI).exists() and os.access(ANI_CLI, os.X_OK)))
result["ani-cli"] = cli_executable_exists(ANI_CLI)
result["anipy-cli"] = cli_executable_exists(ANIPY_CLI)
return result
@@ -166,6 +169,22 @@ def installed_ani_cli_version():
return version or "Unavailable"
@lru_cache(maxsize=1)
def installed_anipy_cli_version():
try:
completed = subprocess.run(
[ANIPY_CLI, "--version"],
check=True,
capture_output=True,
text=True,
timeout=6,
)
except (OSError, subprocess.SubprocessError):
return "Unavailable"
version = str(completed.stdout or completed.stderr or "").strip()
return version or "Unavailable"
class Handler(BaseHTTPRequestHandler):
server_version = "AniCliWeb/1.0"
remote_session_cookie_name = "ani_cli_web_session"
@@ -535,7 +554,14 @@ class Handler(BaseHTTPRequestHandler):
elif parsed.path == "/api/config":
self.json(sanitize_public_config(Handler._context(self).get_config_snapshot()))
elif parsed.path == "/api/version":
self.json({"name": APP_NAME, "version": VERSION, "ani_cli_version": installed_ani_cli_version()})
self.json(
{
"name": APP_NAME,
"version": VERSION,
"ani_cli_version": installed_ani_cli_version(),
"anipy_cli_version": installed_anipy_cli_version(),
}
)
elif parsed.path == "/api/changelog":
self.json({"content": load_project_text_file(CHANGELOG_FILE, default="Changelog unavailable.")})
elif parsed.path == "/api/dependencies":