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:
@@ -26,6 +26,12 @@ export interface MovieRelease {
|
||||
score: number | null;
|
||||
verdict: string | null;
|
||||
rejected_rule: string | null;
|
||||
/**
|
||||
* What the blacklist recorded this release as failing on (#227, §6.3).
|
||||
* Null on every row the blacklist does not hold, and on a blacklisted row
|
||||
* whose entry has since gone — `blacklisted` is then all the record has.
|
||||
*/
|
||||
blacklist_reason: string | null;
|
||||
}
|
||||
|
||||
export type ReleasesOutcome =
|
||||
@@ -113,6 +119,23 @@ export interface SeasonPackState {
|
||||
pack_failures: number;
|
||||
pack_retry_at: string | null;
|
||||
last_pack_search_at: string | null;
|
||||
import_failure: ImportFailure | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A pack that downloaded in full and was condemned at import (#227, §5.7).
|
||||
*
|
||||
* The torrent stays where it is — §7.3 hands that lifecycle to the reaper —
|
||||
* the release is blacklisted and every episode it covered reopens as a gap.
|
||||
* Nothing on screen joined those facts, so the season read `0/10` as though
|
||||
* no grab had ever been tried and the operator found out by opening
|
||||
* Transmission.
|
||||
*/
|
||||
export interface ImportFailure {
|
||||
release: string;
|
||||
/** A policy rule name, or a sentence about the release. See `blacklistClass`. */
|
||||
reason: string | null;
|
||||
failed_at: string | null;
|
||||
}
|
||||
|
||||
export type PackStateOutcome =
|
||||
@@ -257,6 +280,11 @@ export async function grabRelease(movieId: number, releaseId: number): Promise<A
|
||||
* The per-title override one click on a waived row writes (§5.2, §9.3).
|
||||
* Mapping a rule name to its override is bookkeeping, not policy — the
|
||||
* verdict itself always comes from the API.
|
||||
*
|
||||
* `size` relaxes §5.5's floor for this title only, and only into a waiver:
|
||||
* the release stays out of automatic grabbing and imports on the record as
|
||||
* a §5.7 waiver. No band is right for every title, which is why the
|
||||
* override exists at all.
|
||||
*/
|
||||
export function waiverOverride(rule: string | null): Record<string, unknown> | null {
|
||||
switch (rule) {
|
||||
@@ -264,11 +292,18 @@ export function waiverOverride(rule: string | null): Record<string, unknown> | n
|
||||
return { allow_english_audio: true };
|
||||
case "resolution":
|
||||
return { only_4k: false };
|
||||
case "size":
|
||||
return { allow_below_floor: true };
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether one click on this row has an override to write (§9.3). */
|
||||
export function overridable(release: { rejected_rule: string | null }): boolean {
|
||||
return waiverOverride(release.rejected_rule) !== null;
|
||||
}
|
||||
|
||||
export type WaiveOutcome =
|
||||
| { kind: "done"; overrideWritten: boolean }
|
||||
| { kind: "error"; detail: string; overrideWritten: boolean };
|
||||
@@ -455,6 +490,48 @@ export function ruleLabel(rule: string | null): string {
|
||||
return RULE_LABEL[rule] ?? rule.replaceAll("_", " ");
|
||||
}
|
||||
|
||||
/**
|
||||
* What a blacklisting was: the policy turning a file down, or the release
|
||||
* itself failing (#227).
|
||||
*
|
||||
* The blacklist reason is either a policy rule name — the same vocabulary
|
||||
* `rejected_rule` uses — or a sentence about the release, written where the
|
||||
* import gave up before any rule was consulted. The two demand opposite
|
||||
* decisions: a size rejection is the operator's own floor and they can relax
|
||||
* it, a corrupt or mismatched pack is not theirs to argue with. `unknown` is
|
||||
* a row the blacklist no longer answers for; nothing is claimed about it.
|
||||
*/
|
||||
export type BlacklistClass = "policy" | "release" | "unknown";
|
||||
|
||||
export function blacklistClass(reason: string | null): BlacklistClass {
|
||||
if (reason === null) {
|
||||
return "unknown";
|
||||
}
|
||||
return reason in RULE_LABEL ? "policy" : "release";
|
||||
}
|
||||
|
||||
/** The reason as a chip word: a rule's short label, or the sentence itself. */
|
||||
export function blacklistReasonLabel(reason: string | null): string {
|
||||
return reason === null ? "reason not recorded" : (RULE_LABEL[reason] ?? reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* What the operator does about it, which is the whole difference between the
|
||||
* two classes — and the sentence #227 exists to put on screen.
|
||||
*/
|
||||
export function blacklistAdvice(reason: string | null): string {
|
||||
switch (blacklistClass(reason)) {
|
||||
case "policy":
|
||||
return waiverOverride(reason) === null
|
||||
? "policy rejected the file — that rule has no per-title relaxation"
|
||||
: `policy rejected the file — relax ${ruleLabel(reason)} for this title and the next candidate can pass`;
|
||||
case "release":
|
||||
return "the release itself failed at import — a retry downloads the same files";
|
||||
default:
|
||||
return "blacklisted before the reason was recorded";
|
||||
}
|
||||
}
|
||||
|
||||
export async function errorDetail(response: Response): Promise<string> {
|
||||
try {
|
||||
const body = (await response.json()) as { error?: string };
|
||||
|
||||
Reference in New Issue
Block a user