Add TV and movie watchlist download tags
This commit is contained in:
+40
-1
@@ -727,6 +727,12 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
<option value="dropped">Dropped</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>Media type
|
||||
<select id="watchlist-media-type">
|
||||
<option value="tv">TV</option>
|
||||
<option value="movie">Movie</option>
|
||||
</select>
|
||||
</label>
|
||||
<div class="field-hint">Tip: you can also add entries directly from the Search page.</div>
|
||||
<button class="primary" type="submit">Add to watchlist</button>
|
||||
</form>
|
||||
@@ -861,6 +867,10 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
finished: "Finished",
|
||||
dropped: "Dropped"
|
||||
};
|
||||
const mediaTypeLabels = {
|
||||
tv: "TV",
|
||||
movie: "Movie"
|
||||
};
|
||||
const autoDownloadOverlay = document.getElementById("autoDownloadOverlay");
|
||||
const altTitlesOverlay = document.getElementById("altTitlesOverlay");
|
||||
const altTitlesCloseBtn = document.getElementById("altTitlesCloseBtn");
|
||||
@@ -940,6 +950,12 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
.join("");
|
||||
}
|
||||
|
||||
function mediaTypeOptions(selected) {
|
||||
return Object.entries(mediaTypeLabels)
|
||||
.map(([value, label]) => `<option value="${value}"${value === selected ? " selected" : ""}>${label}</option>`)
|
||||
.join("");
|
||||
}
|
||||
|
||||
function renderSummary(summary) {
|
||||
const totals = summary || { shows: 0, sub: 0, dub: 0 };
|
||||
const cards = $("watchlist-summary").querySelectorAll(".summary-card");
|
||||
@@ -1343,6 +1359,9 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
<label>Category
|
||||
<select class="category-select">${categoryOptions(item.category)}</select>
|
||||
</label>
|
||||
<label>Media
|
||||
<select class="media-type-select">${mediaTypeOptions(item.media_type || "tv")}</select>
|
||||
</label>
|
||||
</div>
|
||||
<div class="muted card-date"></div>
|
||||
<div class="card-actions">
|
||||
@@ -1372,6 +1391,7 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
}
|
||||
const statusRow = card.querySelector(".status-row");
|
||||
appendStatusTag(statusRow, item.category_label || categoryLabels[item.category] || "Watching");
|
||||
appendStatusTag(statusRow, item.media_type_label || mediaTypeLabels[item.media_type] || "TV");
|
||||
if (item.airing_status) {
|
||||
appendStatusTag(statusRow, item.airing_status);
|
||||
}
|
||||
@@ -1405,6 +1425,7 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
const dubBtn = actionButtons[5];
|
||||
const downloadPicker = card.querySelector(".download-picker");
|
||||
const categorySelect = card.querySelector(".category-select");
|
||||
const mediaTypeSelect = card.querySelector(".media-type-select");
|
||||
categorySelect.addEventListener("change", async () => {
|
||||
categorySelect.disabled = true;
|
||||
try {
|
||||
@@ -1421,6 +1442,22 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
categorySelect.disabled = false;
|
||||
}
|
||||
});
|
||||
mediaTypeSelect.addEventListener("change", async () => {
|
||||
mediaTypeSelect.disabled = true;
|
||||
try {
|
||||
const data = await api("/api/watchlist/update-media-type", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ show_id: item.show_id, media_type: mediaTypeSelect.value })
|
||||
});
|
||||
setNotice(data.message || "Media type updated.");
|
||||
await fetchWatchlist(state.watchlistPage);
|
||||
} catch (error) {
|
||||
setNotice(error.message);
|
||||
mediaTypeSelect.value = item.media_type || "tv";
|
||||
} finally {
|
||||
mediaTypeSelect.disabled = false;
|
||||
}
|
||||
});
|
||||
refreshBtn.addEventListener("click", () => refreshWatchlistItem(item.show_id));
|
||||
downloadBtn.addEventListener("click", () => {
|
||||
const visible = downloadPicker.classList.toggle("visible");
|
||||
@@ -1500,11 +1537,13 @@ WATCHLIST_HTML = r"""<!doctype html>
|
||||
body: JSON.stringify({
|
||||
show_id: showId,
|
||||
title,
|
||||
category: $("watchlist-category").value
|
||||
category: $("watchlist-category").value,
|
||||
media_type: $("watchlist-media-type").value
|
||||
})
|
||||
});
|
||||
$("watchlist-form").reset();
|
||||
$("watchlist-category").value = "watching";
|
||||
$("watchlist-media-type").value = "tv";
|
||||
setNotice(data.message || "Added to watchlist.");
|
||||
await fetchWatchlist();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user