Add selectable animdl download fallback

This commit is contained in:
Dymas
2026-07-19 14:17:13 +02:00
parent 6bec0e068a
commit 6b3745c7e9
10 changed files with 282 additions and 65 deletions
+19 -11
View File
@@ -463,6 +463,7 @@ CONFIG_HTML = r"""<!doctype html>
<p id="versionLine">Loading version...</p>
<p id="aniCliVersionLine">Detecting ani-cli version...</p>
<p id="anipyCliVersionLine">Detecting anipy-cli fallback...</p>
<p id="animdlVersionLine">Detecting animdl fallback...</p>
<p>Saved settings live in `.ani-cli-web/config.json` inside this project.</p>
</div>
<button class="ghost wide-button" id="openChangelogBtn" type="button">Changelog</button>
@@ -512,18 +513,15 @@ CONFIG_HTML = r"""<!doctype html>
<div class="toolbar">
<div>
<h2>Download fallback</h2>
<p class="muted">If a queued `ani-cli` download fails, optionally retry it once with `anipy-cli`.</p>
<p class="muted">Choose the download methods queue jobs may use, in fallback order.</p>
</div>
</div>
<div class="form-grid">
<label>Automatic retry with anipy-cli
<select id="anipyCliFallbackEnabled">
<option value="false">Disabled</option>
<option value="true">Enabled</option>
</select>
</label>
<div class="check-grid">
<label class="check-item"><input class="download-method" type="checkbox" value="ani-cli"> <span>ani-cli</span></label>
<label class="check-item"><input class="download-method" type="checkbox" value="anipy-cli"> <span>anipy-cli</span></label>
<label class="check-item"><input class="download-method" type="checkbox" value="animdl"> <span>animdl</span></label>
</div>
<div class="field-hint">This only kicks in after an `ani-cli` failure. Install `anipy-cli` separately and keep it in `PATH` if you enable this option.</div>
<div class="field-hint">Jobs try checked methods in this order: ani-cli, anipy-cli, animdl. With one method checked, fallback retry is disabled.</div>
</section>
<section class="settings settings-main">
@@ -687,6 +685,7 @@ CONFIG_HTML = r"""<!doctype html>
quality: "best",
download_dir: "",
anipy_cli_fallback_enabled: false,
download_methods: ["ani-cli"],
watchlist_auto_refresh_enabled: false,
watchlist_auto_refresh_minutes: 60,
watchlist_refresh_delay_seconds: 5,
@@ -748,12 +747,17 @@ CONFIG_HTML = r"""<!doctype html>
return [...document.querySelectorAll(".webhook-event:checked")].map((input) => input.value);
}
function selectedDownloadMethods() {
const methods = [...document.querySelectorAll(".download-method:checked")].map((input) => input.value);
return methods.length ? methods : ["ani-cli"];
}
function formConfigPayload() {
return {
download_dir: $("downloadDir").value,
mode: $("configMode").value,
quality: $("configQuality").value,
anipy_cli_fallback_enabled: $("anipyCliFallbackEnabled").value === "true",
download_methods: selectedDownloadMethods(),
watchlist_auto_refresh_enabled: $("watchlistAutoRefreshEnabled").value === "true",
watchlist_auto_refresh_minutes: $("watchlistAutoRefreshMinutes").value,
watchlist_refresh_delay_seconds: $("watchlistRefreshDelaySeconds").value,
@@ -773,7 +777,10 @@ CONFIG_HTML = r"""<!doctype html>
$("downloadDir").value = data.download_dir;
$("configMode").value = data.mode;
$("configQuality").value = data.quality;
$("anipyCliFallbackEnabled").value = String(Boolean(data.anipy_cli_fallback_enabled));
const methods = new Set(data.download_methods || ["ani-cli"]);
for (const input of document.querySelectorAll(".download-method")) {
input.checked = methods.has(input.value);
}
$("watchlistAutoRefreshEnabled").value = String(Boolean(data.watchlist_auto_refresh_enabled));
$("watchlistAutoRefreshMinutes").value = data.watchlist_auto_refresh_minutes;
$("watchlistRefreshDelaySeconds").value = data.watchlist_refresh_delay_seconds;
@@ -984,6 +991,7 @@ CONFIG_HTML = r"""<!doctype html>
$("versionLine").textContent = `${data.name} ${data.version}`;
$("aniCliVersionLine").textContent = `ani-cli ${data.ani_cli_version || "Unavailable"}`;
$("anipyCliVersionLine").textContent = `anipy-cli ${data.anipy_cli_version || "Unavailable"}`;
$("animdlVersionLine").textContent = `animdl ${data.animdl_version || "Unavailable"}`;
}
async function openChangelog() {