Merge main into blitz/subtitles
Feedback pass 2 and the size-band work landed on main while this branch was finishing. Brings them in ahead of the merge back. # Conflicts: # crates/arr-api/src/movies.rs # crates/arr-api/src/state.rs # crates/arr-daemon/src/main.rs # web/src/main.ts
This commit is contained in:
+364
-83
@@ -5,6 +5,7 @@ import {
|
||||
probeHealth,
|
||||
type SubtitleHealth,
|
||||
} from "./health";
|
||||
import { armedDeleteIcon, icon, SVG_NS } from "./icons";
|
||||
import {
|
||||
fetchLibrary,
|
||||
type LibrarySeries,
|
||||
@@ -44,6 +45,9 @@ import {
|
||||
} from "./queues";
|
||||
import {
|
||||
type ActionOutcome,
|
||||
blacklistAdvice,
|
||||
blacklistClass,
|
||||
blacklistReasonLabel,
|
||||
bucketOf,
|
||||
type FilesOutcome,
|
||||
formatAudio,
|
||||
@@ -56,11 +60,14 @@ import {
|
||||
formatSource,
|
||||
formatSweepAge,
|
||||
grabRelease,
|
||||
type ImportFailure,
|
||||
libraryFolder,
|
||||
type MovieRelease,
|
||||
movieFiles,
|
||||
movieReleases,
|
||||
movieSearchState,
|
||||
overridable,
|
||||
type PackStateOutcome,
|
||||
probedAttributeTags,
|
||||
queueSearch,
|
||||
removeMovie,
|
||||
@@ -70,7 +77,6 @@ import {
|
||||
totalSize,
|
||||
type WaiveOutcome,
|
||||
waiveAndGrab,
|
||||
waiverOverride,
|
||||
} from "./releases";
|
||||
import { currentRoute, navigate, type Route } from "./router";
|
||||
import {
|
||||
@@ -112,9 +118,10 @@ import {
|
||||
setEpisodeWanted,
|
||||
setSeasonTracked,
|
||||
type TvTarget,
|
||||
updateSeries,
|
||||
waiveAndGrabTv,
|
||||
} from "./series";
|
||||
import { armedDelete, settingsMain } from "./settings";
|
||||
import { settingsMain } from "./settings";
|
||||
import "./style.css";
|
||||
import {
|
||||
deleteSubtitle,
|
||||
@@ -482,14 +489,14 @@ function main() {
|
||||
must<HTMLElement>("#library"),
|
||||
{ kind: "library" },
|
||||
);
|
||||
// no origin click to restore focus to on a deep link — the series
|
||||
// view's back control is the closest stand-in
|
||||
// no origin click to restore focus to on a deep link — the library
|
||||
// rail button is the closest stand-in
|
||||
tvDeck.open({
|
||||
title,
|
||||
sub,
|
||||
seriesId,
|
||||
target,
|
||||
origin: must<HTMLButtonElement>("#series-back"),
|
||||
origin: must<HTMLElement>("#nav-library"),
|
||||
returnTo: must<HTMLElement>("#series"),
|
||||
parentRoute: { kind: "series", seriesId },
|
||||
});
|
||||
@@ -808,6 +815,18 @@ function searchMain(
|
||||
return { showIdle, restore };
|
||||
}
|
||||
|
||||
/**
|
||||
* What the operator reads for the stored `blocked` flag. §6.3 gives it one
|
||||
* effect — it stops the targeted-search lane and leaves RSS matching on —
|
||||
* and "blocked" reads as "block this title outright", which is the wrong
|
||||
* promise. The flag, the column and the API keep their name; only the words
|
||||
* on screen say what it does. [`BLOCKED_EFFECT`] carries the RSS half.
|
||||
*/
|
||||
const NO_TARGETED_SEARCH = "no targeted search";
|
||||
|
||||
/** The half a three-word label cannot hold, for titles and accessible names. */
|
||||
const BLOCKED_EFFECT = "arr stops searching for this title; RSS still matches it";
|
||||
|
||||
function chip(text: string, extra?: (chip: HTMLSpanElement) => void): HTMLSpanElement {
|
||||
const span = document.createElement("span");
|
||||
span.className = "chip readout";
|
||||
@@ -1750,7 +1769,7 @@ function libraryRow(
|
||||
chips.append(chip("not wanted"));
|
||||
}
|
||||
if (movie.blocked) {
|
||||
chips.append(chip("blocked"));
|
||||
chips.append(chip(NO_TARGETED_SEARCH));
|
||||
}
|
||||
const rating = ratingChip(movie.vote_average);
|
||||
if (rating !== null) {
|
||||
@@ -1783,7 +1802,7 @@ function librarySeriesRow(
|
||||
const root = roots.find((candidate) => candidate.id === series.root_id);
|
||||
chips.append(chip(root ? root.audience : `root ${series.root_id}`));
|
||||
if (series.blocked) {
|
||||
chips.append(chip("blocked"));
|
||||
chips.append(chip(NO_TARGETED_SEARCH));
|
||||
}
|
||||
const rating = ratingChip(series.vote_average);
|
||||
if (rating !== null) {
|
||||
@@ -2083,6 +2102,48 @@ function wireCollapsedToggle(bucket: CollapsedBucketDom) {
|
||||
});
|
||||
}
|
||||
|
||||
/* ---- icon-only controls (#230) ----------------------------------------- */
|
||||
|
||||
// icon() and armedDeleteIcon() live in icons.ts, shared with the settings
|
||||
// rows (#231); the §9.6 painters below stay here as their only consumer.
|
||||
|
||||
/** §9.6 provider marks, drawn and shipped inline — never a remote image. */
|
||||
function providerMark(name: "tmdb" | "tvdb" | "imdb" | "rt"): SVGSVGElement {
|
||||
const svg = document.createElementNS(SVG_NS, "svg");
|
||||
svg.setAttribute("class", "icon icon-mark");
|
||||
svg.setAttribute("aria-hidden", "true");
|
||||
if (name === "rt") {
|
||||
svg.setAttribute("viewBox", "0 0 20 20");
|
||||
const paths = [
|
||||
"M10 6.6c4.1 0 6.8 2.1 6.8 5.2 0 3.3-3 5.7-6.8 5.7s-6.8-2.4-6.8-5.7c0-3.1 2.7-5.2 6.8-5.2Z",
|
||||
"M10 6.6C8.6 7.1 7 6.8 5.9 5.8",
|
||||
"M10 6.6c1.4.5 3 .2 4.1-.8",
|
||||
"M10 6.6c-.3-1.2 0-2.3.9-3.2",
|
||||
];
|
||||
for (const d of paths) {
|
||||
const path = document.createElementNS(SVG_NS, "path");
|
||||
path.setAttribute("d", d);
|
||||
svg.append(path);
|
||||
}
|
||||
return svg;
|
||||
}
|
||||
svg.setAttribute("viewBox", "0 0 44 20");
|
||||
const box = document.createElementNS(SVG_NS, "rect");
|
||||
box.setAttribute("x", "1");
|
||||
box.setAttribute("y", "1.5");
|
||||
box.setAttribute("width", "42");
|
||||
box.setAttribute("height", "17");
|
||||
box.setAttribute("rx", "4");
|
||||
const letters = document.createElementNS(SVG_NS, "text");
|
||||
letters.setAttribute("x", "22");
|
||||
letters.setAttribute("y", "13.2");
|
||||
letters.setAttribute("text-anchor", "middle");
|
||||
letters.setAttribute("font-size", "9");
|
||||
letters.textContent = { tmdb: "TMDB", tvdb: "TVDB", imdb: "IMDb" }[name];
|
||||
svg.append(box, letters);
|
||||
return svg;
|
||||
}
|
||||
|
||||
/* ---- §9.6 painters shared by both detail pages ------------------------- */
|
||||
|
||||
/** The drawn star before a TMDB rating — no glyph standing in for an icon. */
|
||||
@@ -2116,20 +2177,21 @@ function closeIcon(): SVGSVGElement {
|
||||
}
|
||||
|
||||
/** External links read as quiet controls; they leave the app entirely. */
|
||||
function externalLink(label: string, href: string): HTMLAnchorElement {
|
||||
function externalLink(mark: SVGSVGElement, label: string, href: string): HTMLAnchorElement {
|
||||
const link = document.createElement("a");
|
||||
link.className = "control control-quiet";
|
||||
link.className = "control control-quiet control-icon";
|
||||
link.href = href;
|
||||
link.target = "_blank";
|
||||
link.rel = "noreferrer";
|
||||
link.textContent = label;
|
||||
link.setAttribute("aria-label", label);
|
||||
link.title = label;
|
||||
link.append(mark);
|
||||
return link;
|
||||
}
|
||||
|
||||
function movieMain(views: HideableView[]): MovieView {
|
||||
const view = must<HTMLElement>("#movie");
|
||||
const deckEl = must<HTMLElement>("#deck");
|
||||
const back = must<HTMLButtonElement>("#movie-back");
|
||||
const statusEl = must<HTMLElement>("#movie-status");
|
||||
const hero = must<HTMLElement>("#movie-hero");
|
||||
const poster = must<HTMLImageElement>("#movie-poster");
|
||||
@@ -2143,6 +2205,10 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
const actionsEl = must<HTMLElement>("#movie-actions");
|
||||
const wanted = must<HTMLButtonElement>("#movie-wanted");
|
||||
const blocked = must<HTMLButtonElement>("#movie-blocked");
|
||||
const blockedNote = must<HTMLElement>("#movie-blocked-note");
|
||||
// the accessible name carries what three words cannot, at rest and on
|
||||
blocked.setAttribute("aria-label", `${NO_TARGETED_SEARCH} — ${BLOCKED_EFFECT}`);
|
||||
blocked.title = BLOCKED_EFFECT;
|
||||
const rootSelect = must<HTMLSelectElement>("#movie-root");
|
||||
const sweep = must<HTMLButtonElement>("#movie-sweep");
|
||||
const remove = must<HTMLButtonElement>("#movie-remove");
|
||||
@@ -2189,7 +2255,7 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
if (!movie) {
|
||||
return { kind: "error", detail: "page closed", overrideWritten: false };
|
||||
}
|
||||
if (bucket === "waived") {
|
||||
if (bucket !== "eligible") {
|
||||
return waiveAndGrab(movie.id, release.id, release.rejected_rule);
|
||||
}
|
||||
const outcome = await grabRelease(movie.id, release.id);
|
||||
@@ -2251,6 +2317,8 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
}
|
||||
titleEl.textContent = movie.title;
|
||||
yearEl.textContent = movie.year === null ? "" : String(movie.year);
|
||||
remove.setAttribute("aria-label", `remove ${movie.title} from the library`);
|
||||
remove.title = `remove ${movie.title} from the library`;
|
||||
chipsEl.replaceChildren();
|
||||
const root = roots.find((candidate) => candidate.id === movie.root_id);
|
||||
chipsEl.append(chip(root ? root.audience : `root ${movie.root_id}`));
|
||||
@@ -2265,7 +2333,7 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
);
|
||||
}
|
||||
if (movie.blocked) {
|
||||
chipsEl.append(chip("blocked"));
|
||||
chipsEl.append(chip(NO_TARGETED_SEARCH));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2286,6 +2354,10 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
}
|
||||
wanted.setAttribute("aria-pressed", String(movie.wanted));
|
||||
blocked.setAttribute("aria-pressed", String(movie.blocked));
|
||||
// §6.3 is the whole point of the flag and a bare toggle hides it: the
|
||||
// note appears when the flag is on, which is when the RSS half is the
|
||||
// thing that surprises. At rest the label and the title carry it.
|
||||
blockedNote.hidden = !movie.blocked;
|
||||
paintRootOptions();
|
||||
// a root list that does not carry the title's own root still shows it —
|
||||
// a select lying by omission would make the next change move it blindly
|
||||
@@ -2340,7 +2412,7 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
void updateMovie(movie.id, { blocked: !movie.blocked }).then((outcome) => {
|
||||
if (outcome.kind === "error") {
|
||||
blocked.disabled = false;
|
||||
setStatus(`blocked failed — ${outcome.detail}`, "fault");
|
||||
setStatus(`targeted search change failed — ${outcome.detail}`, "fault");
|
||||
return;
|
||||
}
|
||||
void refreshMovie().then(() => {
|
||||
@@ -2443,13 +2515,26 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
trailer.textContent = "trailer";
|
||||
actionsEl.append(trailer);
|
||||
}
|
||||
actionsEl.append(externalLink("tmdb", tmdbMovieLink(detail.tmdb_id)));
|
||||
const linkTitle = current?.title ?? "this movie";
|
||||
actionsEl.append(
|
||||
externalLink(
|
||||
providerMark("tmdb"),
|
||||
`open ${linkTitle} on TMDB`,
|
||||
tmdbMovieLink(detail.tmdb_id),
|
||||
),
|
||||
);
|
||||
if (detail.imdb_id !== null) {
|
||||
actionsEl.append(externalLink("imdb", imdbLink(detail.imdb_id)));
|
||||
actionsEl.append(
|
||||
externalLink(providerMark("imdb"), `open ${linkTitle} on IMDb`, imdbLink(detail.imdb_id)),
|
||||
);
|
||||
}
|
||||
if (current !== null) {
|
||||
actionsEl.append(
|
||||
externalLink("rotten tomatoes", rottenTomatoesSearch(current.title, current.year)),
|
||||
externalLink(
|
||||
providerMark("rt"),
|
||||
`search Rotten Tomatoes for ${current.title}`,
|
||||
rottenTomatoesSearch(current.title, current.year),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2777,7 +2862,8 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
filesSection.hidden = true;
|
||||
diskRows.replaceChildren();
|
||||
sweep.disabled = false;
|
||||
back.focus();
|
||||
titleEl.setAttribute("tabindex", "-1");
|
||||
titleEl.focus();
|
||||
await load();
|
||||
}
|
||||
|
||||
@@ -2800,8 +2886,6 @@ function movieMain(views: HideableView[]): MovieView {
|
||||
target?.focus();
|
||||
}
|
||||
|
||||
back.addEventListener("click", close);
|
||||
|
||||
// capture + stopImmediatePropagation: one Escape steps back one layer —
|
||||
// the library and search decks also listen for Escape on this window
|
||||
window.addEventListener(
|
||||
@@ -2962,7 +3046,8 @@ function removePanel(subject: RemoveSubject, actions: RemoveActions): HTMLElemen
|
||||
interface ReleaseActions {
|
||||
reload: () => Promise<void>;
|
||||
notify: (text: string, tone?: "fault") => void;
|
||||
/** One click on grab — a plain grab, or waive-then-grab on a waived row. */
|
||||
/** One click on grab — a plain grab, or waive-then-grab where the rule
|
||||
* that failed has an override (§9.3). */
|
||||
grab: (
|
||||
release: MovieRelease,
|
||||
bucket: "eligible" | "waived" | "rejected",
|
||||
@@ -3026,10 +3111,23 @@ function paintBuckets(dom: BucketsDom, releases: MovieRelease[], actions: Releas
|
||||
dom.eligible.rows.append(releaseRow(release, "eligible", scoreStop, actions));
|
||||
}
|
||||
} else {
|
||||
// §9.3: over-strict filters must be visible, not silently absent
|
||||
// §9.3: over-strict filters must be visible, not silently absent — and
|
||||
// where a rule can be waived, the count says so rather than leaving the
|
||||
// way out folded inside a collapsed bucket.
|
||||
//
|
||||
// Only a rejected row needs forcing. A row below policy is offered
|
||||
// already, one click, whatever its rule — and since #211 gave it a rule
|
||||
// at all, counting every overridable row here claimed the whole
|
||||
// collapsed deck had to be forced.
|
||||
const forceable = releases.filter(
|
||||
(release) => bucketOf(release) === "rejected" && overridable(release),
|
||||
).length;
|
||||
const none = document.createElement("li");
|
||||
none.className = "rel rel-none readout dim";
|
||||
none.textContent = "none — every candidate was waived or rejected by policy";
|
||||
none.textContent =
|
||||
forceable > 0
|
||||
? `none — every candidate is below policy or rejected; ${forceable} can be force grabbed`
|
||||
: "none — every candidate is below policy or rejected";
|
||||
dom.eligible.rows.append(none);
|
||||
}
|
||||
for (const name of ["waived", "rejected"] as const) {
|
||||
@@ -3116,7 +3214,7 @@ function buildBucketDom(root: HTMLElement): BucketsDom {
|
||||
|
||||
const dom: BucketsDom = {
|
||||
eligible: { section: eligibleSection, count: eligibleCount, rows: eligibleRows },
|
||||
waived: collapsed("waived"),
|
||||
waived: collapsed("below policy"),
|
||||
rejected: collapsed("rejected"),
|
||||
};
|
||||
root.append(dom.eligible.section, dom.waived.section, dom.rejected.section);
|
||||
@@ -3165,10 +3263,36 @@ function releaseRow(
|
||||
}),
|
||||
);
|
||||
}
|
||||
// #227: a blacklisted release was grabbed, downloaded and condemned at
|
||||
// import. Which of the two things happened decides what the operator does
|
||||
// next, and `blacklisted` alone reads the same for both.
|
||||
const blacklisted =
|
||||
bucket === "rejected" && release.rejected_rule === "blacklisted"
|
||||
? blacklistClass(release.blacklist_reason)
|
||||
: null;
|
||||
if (bucket !== "eligible") {
|
||||
// §9.3: every row that is not eligible names the rule behind it, waived
|
||||
// and rejected alike — three waivers for three different reasons read
|
||||
// identically otherwise, and reading release names to tell them apart is
|
||||
// the Radarr defect this view exists to fix. #211 gave a waived row the
|
||||
// rule it relaxed; a row written before it still has none, and says the
|
||||
// plainer thing alone.
|
||||
const verdict =
|
||||
bucket === "waived"
|
||||
? release.rejected_rule
|
||||
? `below policy · ${ruleLabel(release.rejected_rule)}`
|
||||
: "below policy"
|
||||
: blacklisted
|
||||
? `blacklisted · ${blacklistReasonLabel(release.blacklist_reason)}`
|
||||
: release.rejected_rule
|
||||
? `rejected · ${ruleLabel(release.rejected_rule)}`
|
||||
: "rejected";
|
||||
line.append(
|
||||
chip(`${bucket} · ${ruleLabel(release.rejected_rule)}`, (span) => {
|
||||
chip(verdict, (span) => {
|
||||
span.dataset.verdict = bucket;
|
||||
if (blacklisted) {
|
||||
span.dataset.blacklist = blacklisted;
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -3177,6 +3301,13 @@ function releaseRow(
|
||||
name.className = "rel-name readout";
|
||||
name.textContent = release.name;
|
||||
line.append(name);
|
||||
if (blacklisted) {
|
||||
const why = document.createElement("span");
|
||||
why.className = "rel-why readout";
|
||||
why.dataset.blacklist = blacklisted;
|
||||
why.textContent = blacklistAdvice(release.blacklist_reason);
|
||||
line.append(why);
|
||||
}
|
||||
item.append(line);
|
||||
|
||||
const note = document.createElement("span");
|
||||
@@ -3184,12 +3315,22 @@ function releaseRow(
|
||||
note.setAttribute("role", "status");
|
||||
note.hidden = true;
|
||||
|
||||
if (bucket !== "rejected") {
|
||||
// A rejected row is normally inert, but §9.3's one click is exactly for
|
||||
// the rule the operator disagrees with: where an override exists, the row
|
||||
// offers it and the grab that follows stays a waiver.
|
||||
const writesOverride = bucket !== "eligible" && overridable(release);
|
||||
if (bucket !== "rejected" || writesOverride) {
|
||||
const grab = document.createElement("button");
|
||||
grab.type = "button";
|
||||
grab.className = "control rel-grab";
|
||||
const writesOverride = bucket === "waived" && waiverOverride(release.rejected_rule) !== null;
|
||||
grab.textContent = writesOverride ? "waive + grab" : "grab";
|
||||
// "force grab" says what the click does; the accessible name says what
|
||||
// it forces past, since the rule is the reason the row is not eligible.
|
||||
grab.textContent = writesOverride ? "force grab" : "grab";
|
||||
if (writesOverride) {
|
||||
const forced = `force grab — relaxes ${ruleLabel(release.rejected_rule)} for this title and grabs anyway`;
|
||||
grab.setAttribute("aria-label", forced);
|
||||
grab.title = forced;
|
||||
}
|
||||
grab.addEventListener("click", () => {
|
||||
grab.disabled = true;
|
||||
note.hidden = false;
|
||||
@@ -3462,7 +3603,7 @@ function seriesRow(
|
||||
);
|
||||
}
|
||||
if (series.blocked) {
|
||||
chips.append(chip("blocked"));
|
||||
chips.append(chip(NO_TARGETED_SEARCH));
|
||||
}
|
||||
chips.append(
|
||||
chip(series.status, (span) => {
|
||||
@@ -3574,7 +3715,7 @@ function seriesCard(
|
||||
);
|
||||
}
|
||||
if (series.blocked) {
|
||||
chips.push(chip("blocked"));
|
||||
chips.push(chip(NO_TARGETED_SEARCH));
|
||||
}
|
||||
chips.push(
|
||||
chip(series.status, (span) => {
|
||||
@@ -3611,7 +3752,7 @@ function movieCard(
|
||||
chips.push(chip("not wanted"));
|
||||
}
|
||||
if (movie.blocked) {
|
||||
chips.push(chip("blocked"));
|
||||
chips.push(chip(NO_TARGETED_SEARCH));
|
||||
}
|
||||
const rating = ratingChip(movie.vote_average);
|
||||
if (rating !== null) {
|
||||
@@ -3650,6 +3791,10 @@ function tvReleasesMain(): TvReleasesView {
|
||||
const sub = must<HTMLElement>("#tv-releases-sub");
|
||||
const sweep = must<HTMLButtonElement>("#tv-releases-sweep");
|
||||
const statusEl = must<HTMLElement>("#tv-releases-status");
|
||||
const failureEl = must<HTMLElement>("#tv-releases-failure");
|
||||
const failureRelease = must<HTMLElement>("#tv-failure-release");
|
||||
const failureWhat = must<HTMLElement>("#tv-failure-what");
|
||||
const failureNext = must<HTMLElement>("#tv-failure-next");
|
||||
const dom = buildBucketDom(must<HTMLElement>("#tv-buckets"));
|
||||
|
||||
let request: TvDeckRequest | null = null;
|
||||
@@ -3692,15 +3837,49 @@ function tvReleasesMain(): TvReleasesView {
|
||||
statusEl.dataset.action = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* #227: the season's own history, above the candidates. A pack that
|
||||
* downloaded in full and was condemned at import (§5.7) blacklists the
|
||||
* release and puts every episode back to `missing`, which leaves the season
|
||||
* reading `0/10` as though nothing had ever been tried. It sits outside the
|
||||
* status line because it is a fact about the season, not about the request
|
||||
* in flight, and it has to survive a sweep that repaints the status.
|
||||
*/
|
||||
function paintFailure(failure: ImportFailure | null) {
|
||||
if (failure === null) {
|
||||
failureEl.hidden = true;
|
||||
return;
|
||||
}
|
||||
failureEl.dataset.blacklist = blacklistClass(failure.reason);
|
||||
failureEl.hidden = false;
|
||||
failureRelease.textContent =
|
||||
failure.failed_at === null
|
||||
? failure.release
|
||||
: `${failure.release} · ${formatSweepAge(failure.failed_at)}`;
|
||||
// A rule name reads as a preposition — "condemned on size"; a reason
|
||||
// written as a sentence has to be quoted, not conjugated.
|
||||
const on =
|
||||
blacklistClass(failure.reason) === "policy"
|
||||
? ` on ${blacklistReasonLabel(failure.reason)}`
|
||||
: "";
|
||||
const said = blacklistClass(failure.reason) === "release" ? `${failure.reason}. ` : "";
|
||||
failureWhat.textContent = `downloaded in full, then condemned at import${on} — ${said}every episode went back to missing and the release is blacklisted.`;
|
||||
failureNext.textContent = `${blacklistAdvice(failure.reason)}.`;
|
||||
}
|
||||
|
||||
const actions: ReleaseActions = {
|
||||
reload: () => load(),
|
||||
notify: (text, tone) => setStatus(text, tone),
|
||||
grab: (release, bucket) => {
|
||||
const current = request;
|
||||
if (!current) {
|
||||
return Promise.resolve({ kind: "error", detail: "deck closed", overrideWritten: false });
|
||||
return Promise.resolve({
|
||||
kind: "error",
|
||||
detail: "releases closed",
|
||||
overrideWritten: false,
|
||||
});
|
||||
}
|
||||
if (bucket === "waived") {
|
||||
if (bucket !== "eligible") {
|
||||
return waiveAndGrabTv(current.seriesId, current.target, release.id, release.rejected_rule);
|
||||
}
|
||||
return current.target
|
||||
@@ -3731,9 +3910,17 @@ function tvReleasesMain(): TvReleasesView {
|
||||
setStatus(`releases unavailable — ${outcome.detail}`, "fault");
|
||||
return;
|
||||
}
|
||||
if (!paintBuckets(dom, outcome.releases, actions)) {
|
||||
const painted = paintBuckets(dom, outcome.releases, actions);
|
||||
// One read of the season's state, shared by the notice and the empty
|
||||
// verdict below — they answer two questions from the same row.
|
||||
const pack = await current.target.packState?.();
|
||||
if (ticket !== sequence || request !== current) {
|
||||
return;
|
||||
}
|
||||
paintFailure(pack?.kind === "state" ? pack.state.import_failure : null);
|
||||
if (!painted) {
|
||||
clearBuckets(dom);
|
||||
await emptyVerdict(current, ticket, sweepIfEmpty);
|
||||
await emptyVerdict(current, ticket, sweepIfEmpty, pack);
|
||||
return;
|
||||
}
|
||||
setStatus(null);
|
||||
@@ -3747,8 +3934,13 @@ function tvReleasesMain(): TvReleasesView {
|
||||
* answers the third; `last_pack_search_at` separates the first two, the
|
||||
* same way a movie's `last_searched_at` does (#177).
|
||||
*/
|
||||
async function emptyVerdict(current: TvDeckRequest, ticket: number, sweepIfEmpty: boolean) {
|
||||
const outcome = await current.target.packState?.();
|
||||
async function emptyVerdict(
|
||||
current: TvDeckRequest,
|
||||
ticket: number,
|
||||
sweepIfEmpty: boolean,
|
||||
known?: PackStateOutcome,
|
||||
) {
|
||||
const outcome = known ?? (await current.target.packState?.());
|
||||
if (ticket !== sequence || request !== current) {
|
||||
return;
|
||||
}
|
||||
@@ -3840,6 +4032,9 @@ function tvReleasesMain(): TvReleasesView {
|
||||
if (ticket !== sequence || request !== current) {
|
||||
return;
|
||||
}
|
||||
if (state?.kind === "state") {
|
||||
paintFailure(state.state.import_failure);
|
||||
}
|
||||
if (state?.kind === "state" && state.state.last_pack_search_at !== baseline) {
|
||||
sweep.disabled = false;
|
||||
await emptyVerdict(current, ticket, false);
|
||||
@@ -3912,6 +4107,7 @@ function tvReleasesMain(): TvReleasesView {
|
||||
next.returnTo.hidden = true;
|
||||
view.hidden = false;
|
||||
clearBuckets(dom);
|
||||
paintFailure(null);
|
||||
sweep.disabled = false;
|
||||
back.focus();
|
||||
void load(true);
|
||||
@@ -3980,7 +4176,6 @@ const SERIES_REFRESH_WAIT_MS = 30_000;
|
||||
function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
const view = must<HTMLElement>("#series");
|
||||
const deckEl = must<HTMLElement>("#deck");
|
||||
const back = must<HTMLButtonElement>("#series-back");
|
||||
const hero = must<HTMLElement>("#series-hero");
|
||||
const poster = must<HTMLImageElement>("#series-poster");
|
||||
const titleEl = must<HTMLElement>("#series-title");
|
||||
@@ -3993,6 +4188,7 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
const actionsEl = must<HTMLElement>("#series-actions");
|
||||
const statusEl = must<HTMLElement>("#series-status");
|
||||
const seasonsList = must<HTMLUListElement>("#rows-seasons");
|
||||
const rootSelect = must<HTMLSelectElement>("#series-root");
|
||||
const remove = must<HTMLButtonElement>("#series-remove");
|
||||
const removeWrap = must<HTMLElement>("#series-remove-panel");
|
||||
|
||||
@@ -4087,6 +4283,8 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
}
|
||||
titleEl.textContent = current.title;
|
||||
yearEl.textContent = current.year === null ? "" : String(current.year);
|
||||
remove.setAttribute("aria-label", `remove ${current.title} from the library`);
|
||||
remove.title = `remove ${current.title} from the library`;
|
||||
chipsEl.replaceChildren();
|
||||
const root = roots.find((candidate) => candidate.id === current.root_id);
|
||||
chipsEl.append(chip(root ? root.audience : `root ${current.root_id}`));
|
||||
@@ -4104,10 +4302,53 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
}),
|
||||
);
|
||||
if (current.blocked) {
|
||||
chipsEl.append(chip("blocked"));
|
||||
chipsEl.append(chip(NO_TARGETED_SEARCH));
|
||||
}
|
||||
}
|
||||
|
||||
function paintRootControl() {
|
||||
const current = series;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
rootSelect.replaceChildren();
|
||||
for (const root of roots.filter((candidate) => candidate.kind === "tv")) {
|
||||
const option = document.createElement("option");
|
||||
option.value = String(root.id);
|
||||
option.textContent = `${root.audience} · ${root.policy_name}`;
|
||||
rootSelect.append(option);
|
||||
}
|
||||
if (rootSelect.value !== String(current.root_id)) {
|
||||
const option = document.createElement("option");
|
||||
option.value = String(current.root_id);
|
||||
option.textContent = `root ${current.root_id}`;
|
||||
rootSelect.append(option);
|
||||
}
|
||||
rootSelect.value = String(current.root_id);
|
||||
}
|
||||
|
||||
rootSelect.addEventListener("change", () => {
|
||||
const current = series;
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
const next = Number(rootSelect.value);
|
||||
if (!Number.isInteger(next) || next === current.root_id) {
|
||||
return;
|
||||
}
|
||||
rootSelect.disabled = true;
|
||||
void updateSeries(current.id, { root_id: next }).then((outcome) => {
|
||||
rootSelect.disabled = false;
|
||||
if (outcome.kind === "error") {
|
||||
rootSelect.value = String(current.root_id);
|
||||
setStatus(`root change failed — ${outcome.detail}`, "fault");
|
||||
return;
|
||||
}
|
||||
focusKey = "series-root";
|
||||
void load();
|
||||
});
|
||||
});
|
||||
|
||||
/* ---- §9.6 rich detail: one request, images hotlinked ---- */
|
||||
|
||||
function clearRichDetail() {
|
||||
@@ -4189,26 +4430,41 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
trailer.textContent = "trailer";
|
||||
actionsEl.append(trailer);
|
||||
}
|
||||
actionsEl.append(externalLink("tmdb", tmdbSeriesLink(detail.tmdb_id)));
|
||||
const linkTitle = series?.title ?? "this series";
|
||||
actionsEl.append(
|
||||
externalLink(
|
||||
providerMark("tmdb"),
|
||||
`open ${linkTitle} on TMDB`,
|
||||
tmdbSeriesLink(detail.tmdb_id),
|
||||
),
|
||||
);
|
||||
// a series has no imdb_id in this app; TVDB is its second id (§9.6)
|
||||
if (detail.tvdb_id !== null) {
|
||||
actionsEl.append(externalLink("tvdb", tvdbLink(detail.tvdb_id)));
|
||||
actionsEl.append(
|
||||
externalLink(providerMark("tvdb"), `open ${linkTitle} on TVDB`, tvdbLink(detail.tvdb_id)),
|
||||
);
|
||||
}
|
||||
if (series !== null) {
|
||||
actionsEl.append(
|
||||
externalLink("rotten tomatoes", rottenTomatoesSearch(series.title, series.year)),
|
||||
externalLink(
|
||||
providerMark("rt"),
|
||||
`search Rotten Tomatoes for ${series.title}`,
|
||||
rottenTomatoesSearch(series.title, series.year),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function seasonCountsChip(season: ApiSeason): HTMLSpanElement {
|
||||
const counts = seasonCounts(season);
|
||||
return countsChip(
|
||||
`${counts.available}/${counts.wanted} on disk`,
|
||||
const span = countsChip(
|
||||
`${counts.available}/${counts.wanted}`,
|
||||
counts.available,
|
||||
counts.wanted,
|
||||
`${counts.available} of ${counts.wanted} wanted episodes on disk`,
|
||||
);
|
||||
span.prepend(icon("disk"));
|
||||
return span;
|
||||
}
|
||||
|
||||
function seasonRow(season: ApiSeason): HTMLLIElement {
|
||||
@@ -4275,8 +4531,14 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
|
||||
const deckBtn = document.createElement("button");
|
||||
deckBtn.type = "button";
|
||||
deckBtn.className = "control";
|
||||
deckBtn.textContent = "deck";
|
||||
deckBtn.className = "control control-icon";
|
||||
const deckLabel =
|
||||
season.number === 0
|
||||
? "search releases for specials"
|
||||
: `search releases for season ${PAD_TWO(season.number)}`;
|
||||
deckBtn.setAttribute("aria-label", deckLabel);
|
||||
deckBtn.title = deckLabel;
|
||||
deckBtn.append(icon("search"));
|
||||
deckBtn.addEventListener("click", () => {
|
||||
const currentId = seriesId;
|
||||
const currentTitle = series?.title ?? "";
|
||||
@@ -4296,6 +4558,24 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
});
|
||||
|
||||
line.append(disclose, name, track, seasonCountsChip(season));
|
||||
// #227: the season the operator's report is about read `0/10` with
|
||||
// nothing saying a pack had been grabbed, downloaded in full and thrown
|
||||
// out at import. The counts chip beside this one is exactly the number
|
||||
// that looked like nothing was ever tried.
|
||||
const failure = season.import_failure;
|
||||
if (failure) {
|
||||
const kind = blacklistClass(failure.reason);
|
||||
const when = failure.failed_at === null ? "" : ` ${formatSweepAge(failure.failed_at)}`;
|
||||
const told = `a pack for this season downloaded in full and failed at import${when} — ${failure.release} · ${blacklistAdvice(failure.reason)}`;
|
||||
line.append(
|
||||
chip(`import failed · ${blacklistReasonLabel(failure.reason)}`, (span) => {
|
||||
span.dataset.flag = "import-failed";
|
||||
span.dataset.blacklist = kind;
|
||||
span.title = told;
|
||||
span.setAttribute("aria-label", told);
|
||||
}),
|
||||
);
|
||||
}
|
||||
// The season-level twin of the episode flag above: gone upstream while
|
||||
// files under it remained.
|
||||
if (season.vanished) {
|
||||
@@ -4309,26 +4589,25 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
// #174: files go, episodes stop being wanted, the season stays listed.
|
||||
// Only offered with files on disk — intent alone is the tracked toggle.
|
||||
if (season.episodes.some((episode) => filesByEpisode.has(episode.id))) {
|
||||
const clear = armedDelete("remove files", () => {
|
||||
const currentId = seriesId;
|
||||
if (currentId === null) {
|
||||
return;
|
||||
}
|
||||
void removeSeasonFiles(currentId, season.number).then((outcome) => {
|
||||
if (outcome.kind === "error") {
|
||||
clear.disabled = false;
|
||||
setStatus(`remove failed — ${outcome.detail}`, "fault");
|
||||
const clear = armedDeleteIcon(
|
||||
`remove ${season.number === 0 ? "specials" : `season ${PAD_TWO(season.number)}`} files from disk and stop wanting its episodes — the season stays listed`,
|
||||
() => {
|
||||
const currentId = seriesId;
|
||||
if (currentId === null) {
|
||||
return;
|
||||
}
|
||||
// the control itself disappears with the files; the tracked
|
||||
// toggle is the season's control that survives the repaint
|
||||
focusKey = `track-${season.number}`;
|
||||
void load();
|
||||
});
|
||||
});
|
||||
clear.setAttribute(
|
||||
"aria-label",
|
||||
`remove ${season.number === 0 ? "specials" : `season ${PAD_TWO(season.number)}`} files from disk and stop wanting its episodes — the season stays listed`,
|
||||
void removeSeasonFiles(currentId, season.number).then((outcome) => {
|
||||
if (outcome.kind === "error") {
|
||||
clear.disabled = false;
|
||||
setStatus(`remove failed — ${outcome.detail}`, "fault");
|
||||
return;
|
||||
}
|
||||
// the control itself disappears with the files; the tracked
|
||||
// toggle is the season's control that survives the repaint
|
||||
focusKey = `track-${season.number}`;
|
||||
void load();
|
||||
});
|
||||
},
|
||||
);
|
||||
line.append(clear);
|
||||
}
|
||||
@@ -4396,21 +4675,20 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
if (aired && onDisk) {
|
||||
// #174: the file goes and the episode stops being wanted; the row
|
||||
// stays listed. Same arm-then-confirm as a settings row.
|
||||
const clear = armedDelete("remove file", () => {
|
||||
void removeEpisodeFiles(episode.id).then((outcome) => {
|
||||
if (outcome.kind === "error") {
|
||||
clear.disabled = false;
|
||||
setStatus(`remove failed — ${outcome.detail}`, "fault");
|
||||
return;
|
||||
}
|
||||
// once missing, the row's want control is what remains to focus
|
||||
focusKey = `want-${episode.id}`;
|
||||
void load();
|
||||
});
|
||||
});
|
||||
clear.setAttribute(
|
||||
"aria-label",
|
||||
const clear = armedDeleteIcon(
|
||||
`remove the ${episodeTag(seasonNumber, episode.number)} file from disk and stop wanting the episode — it stays listed`,
|
||||
() => {
|
||||
void removeEpisodeFiles(episode.id).then((outcome) => {
|
||||
if (outcome.kind === "error") {
|
||||
clear.disabled = false;
|
||||
setStatus(`remove failed — ${outcome.detail}`, "fault");
|
||||
return;
|
||||
}
|
||||
// once missing, the row's want control is what remains to focus
|
||||
focusKey = `want-${episode.id}`;
|
||||
void load();
|
||||
});
|
||||
},
|
||||
);
|
||||
actions.append(clear);
|
||||
} else if (!aired) {
|
||||
@@ -4441,8 +4719,11 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
|
||||
const deckBtn = document.createElement("button");
|
||||
deckBtn.type = "button";
|
||||
deckBtn.className = "control";
|
||||
deckBtn.textContent = "deck";
|
||||
deckBtn.className = "control control-icon";
|
||||
const deckLabel = `search releases for ${episodeTag(seasonNumber, episode.number)}`;
|
||||
deckBtn.setAttribute("aria-label", deckLabel);
|
||||
deckBtn.title = deckLabel;
|
||||
deckBtn.append(icon("search"));
|
||||
deckBtn.addEventListener("click", () => {
|
||||
const currentId = seriesId;
|
||||
const currentTitle = series?.title ?? "";
|
||||
@@ -4657,6 +4938,7 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
: [],
|
||||
);
|
||||
paintHeader();
|
||||
paintRootControl();
|
||||
clearRichDetail();
|
||||
renderSeasons();
|
||||
syncRefreshWatch(ticket);
|
||||
@@ -4686,7 +4968,8 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
view.hidden = false;
|
||||
clearRemove();
|
||||
clearRichDetail();
|
||||
back.focus();
|
||||
titleEl.setAttribute("tabindex", "-1");
|
||||
titleEl.focus();
|
||||
await load();
|
||||
}
|
||||
|
||||
@@ -4707,8 +4990,6 @@ function seriesMain(tvDeck: TvReleasesView, views: HideableView[]): SeriesView {
|
||||
origin?.focus();
|
||||
}
|
||||
|
||||
back.addEventListener("click", close);
|
||||
|
||||
// capture, like every other layer: the tv deck's listener is registered
|
||||
// first, so one Esc steps back one layer
|
||||
window.addEventListener(
|
||||
|
||||
Reference in New Issue
Block a user