import { NextResponse } from "next/server"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { COPIES_DECIDE_BODY_KEYS, applyCopiesDecision } from "yt-dlp-transcript-common/controller/copiesScan"; import { ops, opsFail } from "../_lib"; export const dynamic = "force-dynamic"; // POST { group, pair: "/|/" | pairs: [...], undo?, note?, by? } // -> { ok, group, action: "confirm", undo, applied, unknown, skipped, now } // // A METADATA-ONLY PAIR CONFIRMED AS ONE RECORDING (lane cross-source-dupes): // the lanes then treat it as a text-confirmed pair — the copy is skipped once // the other copy's work is done, instead of being held until the group's wait // ends and then done twice. Only a metadata-only pair takes it: a part-of or // overlapping pair (the words said it is not a copy of the whole) and a pair // inside one channel are named in `skipped` with the reason. A pair is named // as `get copies` prints its key, or by its two videos (dir or id) in either // order; one the scan does not list is reported in `unknown`. `by` is // "operator" or "agent" (the default), recorded with the time and the note in // `transcripts/copies/.decisions.json`. A confirm replaces a reject of // the same pair; `undo: true` takes the confirm back. Synchronous. export async function POST(request: Request) { return ops(request, COPIES_DECIDE_BODY_KEYS, async (body) => { const out = await applyCopiesDecision(getPaths(), getSettings(), "confirm", body); if (!out.ok) return opsFail(out.error, out.status); return NextResponse.json(out); }); }