// A job's RESULT MARKER read off its log (release 32): several jobs end their // log with one `@@ {json}` line (find-copy, audio-audit, frame-scan…). // A button that ran one — a dry run whose answer is a candidate list — reads // the LAST such line. Client-safe: no server module is imported, so the // marker strings are written here and pinned to the controllers' constants by // resultMarker.test.ts. export const FIND_COPY_MARKER = "@@find-copy "; export const AUDIO_AUDIT_MARKER = "@@audio-audit "; /** The JSON after the last line starting with `marker`, or null (none, or not JSON). */ export function readResultMarker(log: string, marker: string): T | null { const lines = log.split("\n"); for (let i = lines.length - 1; i >= 0; i--) { const line = lines[i]!.trim(); if (!line.startsWith(marker.trim())) continue; try { return JSON.parse(line.slice(marker.trim().length).trim()) as T; } catch { return null; } } return null; } // What the find-copy scope mode's log ends with (publish/findCopy.ts // FindWholeCopiesResult, plus the job's fetchJobId / refused). export type FindCopiesResultView = { gone: "no-transcript" | "all"; dryRun: boolean; max: number; channels: string[]; eligible: number; skipped: { media: number; transcript: number; recent: { slug: string; id: string; at: string; outcome: string }[]; unreadable: { slug: string; error: string }[]; }; looked: { slug: string; id: string; gone: string; noTranscript: boolean; watchUrl: string | null; outcome: "fetch" | "none-found" | "not-youtube" | "error"; via?: string; }[]; left: number; items: unknown[]; stopped?: string; fetchJobId?: string; refused?: string; }; export const FIND_COPY_OUTCOME_TEXT: Record = { fetch: "copy found", "none-found": "no copy found", "not-youtube": "not looked for (not YouTube)", error: "lookup failed, try later", };