Improve auto-download title and series controls

This commit is contained in:
Dymas
2026-05-25 10:02:32 +02:00
parent 3d42657837
commit baea85e24c
8 changed files with 67 additions and 20 deletions
+31 -6
View File
@@ -1127,9 +1127,14 @@ WATCHLIST_HTML = r"""<!doctype html>
<label>Quality
<select class="auto-download-quality">${qualityOptions.replace(`value="${item.auto_download_quality}"`, `value="${item.auto_download_quality}" selected`)}</select>
</label>
<label>Series
<input class="auto-download-series" type="number" min="1" step="1" value="${item.auto_download_series || "1"}">
</label>
<label>Name source
<select class="auto-download-name-select"></select>
</label>
<label>Name
<input class="auto-download-name" type="text" list="auto-download-name-options-${item.show_id}">
<datalist id="auto-download-name-options-${item.show_id}"></datalist>
<input class="auto-download-name" type="text">
</label>
</div>
<div class="auto-download-actions">
@@ -1211,16 +1216,32 @@ WATCHLIST_HTML = r"""<!doctype html>
const autoDownloadPanel = card.querySelector(".auto-download-panel");
const autoDownloadMode = card.querySelector(".auto-download-mode");
const autoDownloadQuality = card.querySelector(".auto-download-quality");
const autoDownloadSeries = card.querySelector(".auto-download-series");
const autoDownloadNameSelect = card.querySelector(".auto-download-name-select");
const autoDownloadName = card.querySelector(".auto-download-name");
const autoDownloadSave = card.querySelector(".auto-download-save");
const autoDownloadNameOptions = card.querySelector(`#auto-download-name-options-${CSS.escape(item.show_id)}`);
autoDownloadName.value = item.auto_download_name || "";
const nameSuggestions = [item.title, ...(Array.isArray(item.alternative_titles) ? item.alternative_titles.map((entry) => entry.value) : [])];
const nameSuggestions = [];
for (const name of [item.title, ...(Array.isArray(item.alternative_titles) ? item.alternative_titles.map((entry) => entry.value) : [])]) {
if (name && !nameSuggestions.includes(name)) nameSuggestions.push(name);
}
for (const name of nameSuggestions) {
const option = document.createElement("option");
option.value = name;
autoDownloadNameOptions.appendChild(option);
option.textContent = name;
autoDownloadNameSelect.appendChild(option);
}
const customOption = document.createElement("option");
customOption.value = "__custom__";
customOption.textContent = "Custom";
autoDownloadNameSelect.appendChild(customOption);
const matchedSuggestion = nameSuggestions.find((name) => name === (item.auto_download_name || ""));
autoDownloadNameSelect.value = matchedSuggestion || "__custom__";
autoDownloadNameSelect.addEventListener("change", () => {
if (autoDownloadNameSelect.value !== "__custom__") {
autoDownloadName.value = autoDownloadNameSelect.value;
}
});
const categorySelect = card.querySelector(".category-select");
categorySelect.addEventListener("change", async () => {
categorySelect.disabled = true;
@@ -1256,10 +1277,14 @@ WATCHLIST_HTML = r"""<!doctype html>
show_id: item.show_id,
mode: autoDownloadMode.value,
quality: autoDownloadQuality.value,
name: autoDownloadName.value
name: autoDownloadName.value,
series: autoDownloadSeries.value
})
});
autoDownloadName.value = (data.item || {}).auto_download_name || autoDownloadName.value;
autoDownloadSeries.value = (data.item || {}).auto_download_series || autoDownloadSeries.value;
const savedName = (data.item || {}).auto_download_name || "";
autoDownloadNameSelect.value = nameSuggestions.includes(savedName) ? savedName : "__custom__";
setNotice(data.message || "Auto-download settings saved.");
} catch (error) {
setNotice(error.message);