commit fbc68b9460087dbedffd2c73bbe3e70da4f77066
parent 6bdfe3294eac7ded24ad63bae89609b79975cbf2
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Fri, 16 Oct 2026 16:57:19 -0400
editor: "Attach video" on each article (reports attach-video as a button)
The Articles tab's row: the article's video (or none), and a video file, a
poster and a caption to attach — an `attach-report-video` job on its own
queue, through publish/reportVideo.ts and the article registry, as
`archilyzer reports attach-video --article` does.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
6 files changed, 134 insertions(+), 2 deletions(-)
diff --git a/common/jobs/jobKinds.test.ts b/common/jobs/jobKinds.test.ts
@@ -105,6 +105,8 @@ const ADDED_KINDS: Record<string, { label: string; drainable: boolean }> = {
"find-copy": { label: "Find copies", drainable: false },
// fetch-copies (release 31): gone videos' whole audio from their copies.
"fetch-copies": { label: "Fetch copies", drainable: true },
+ // An article's own video (release 32): one remux or encode.
+ "attach-report-video": { label: "Attach article video", drainable: false },
};
test("added kinds carry their pinned label and drainability", () => {
diff --git a/common/jobs/jobKinds.ts b/common/jobs/jobKinds.ts
@@ -885,6 +885,21 @@ const JOB_KINDS: Record<string, JobKindMeta> = {
needsMedia: false,
needsText: true,
},
+ // AN ARTICLE'S OWN VIDEO (release 32, the Articles tab's "Attach video";
+ // `archilyzer reports attach-video --article` before it): a file the
+ // operator names, remuxed or encoded to fit the publish limit, written
+ // beside the article's report.json as video.mp4 with a poster, and `video`
+ // set through the article registry. Reads a file outside any channel, so no
+ // media guard. Its own queue (`report-video`): one encode at a time. Not
+ // replayable: the file is a path on some drive.
+ "attach-report-video": {
+ kind: "attach-report-video",
+ label: "Attach article video",
+ drainable: false,
+ replayable: false,
+ queueKeyStrategy: "custom",
+ needsMedia: false,
+ },
// THE PER-VIDEO WRITERS THAT WERE NOT IN THIS TABLE (release 16 slice RM).
// Each runs with a channelSlug and writes under `data/<id>/` — a single
// video's transcription (the video page's two Transcribe buttons, and its
diff --git a/editor/app/sites/articles/page.tsx b/editor/app/sites/articles/page.tsx
@@ -7,6 +7,7 @@ import {
REPORT_EXPORT_FORMATS,
} from "yt-dlp-transcript-common/lib/report/views";
import { ArticleRowActions } from "../components/ArticleRowActions";
+import { ArticleVideoControl } from "../components/ArticleVideoControl";
import { ExportArticlesButton, PrepareArticlesMediaButton } from "../components/ArticlesJobButtons";
import { FetchMissingEvidenceButton } from "../components/FetchMissingEvidenceButton";
import { publishRefusal, reportMediaSummary, type ReportMediaSummary } from "../lib/reportList";
@@ -189,6 +190,7 @@ function ArticleListItem({ row, publishedCount }: { row: ArticleRow; publishedCo
{row.claims === 1 ? "" : "s"} · {row.citations} citation{row.citations === 1 ? "" : "s"}
</p>
)}
+ {row.status !== "missing" && <ArticleVideoControl articleId={row.id} video={row.video} />}
{row.problems.length === 0 ? (
<span className="text-xs text-muted-foreground">{STATUS_TEXT[row.status]}</span>
) : (
diff --git a/editor/app/sites/components/ArticleVideoControl.tsx b/editor/app/sites/components/ArticleVideoControl.tsx
@@ -0,0 +1,47 @@
+"use client";
+
+import { useState } from "react";
+import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActionLog";
+import { cancelJobAction } from "../../jobs/actions";
+import { attachArticleVideoAction } from "../lib/attachVideoAction";
+
+// An article's own video (release 32; `archilyzer reports attach-video
+// --article` before it): a file on this machine, remuxed or encoded to fit the
+// publish limit, beside the article as video.mp4 with a poster.
+export function ArticleVideoControl({ articleId, video }: { articleId: string; video: string | null }) {
+ const [file, setFile] = useState("");
+ const [poster, setPoster] = useState("");
+ const [caption, setCaption] = useState("");
+ const input = "rounded border border-border bg-card px-2 py-1 text-sm font-mono";
+ return (
+ <details className="text-sm" aria-label={`video of ${articleId}`}>
+ <summary className="cursor-pointer select-none text-xs text-muted-foreground">
+ {video ? `Video: ${video}` : "No video"} · Attach video
+ </summary>
+ <div className="mt-2 flex flex-col gap-2">
+ <div className="flex flex-wrap gap-3">
+ <label className="flex flex-col gap-0.5">
+ <span className="text-xs text-muted-foreground">Video file (absolute path)</span>
+ <input value={file} onChange={(e) => setFile(e.target.value)} aria-label={`video file for ${articleId}`} className={`${input} w-96 max-w-full`} />
+ </label>
+ <label className="flex flex-col gap-0.5">
+ <span className="text-xs text-muted-foreground">Poster image (optional)</span>
+ <input value={poster} onChange={(e) => setPoster(e.target.value)} aria-label={`poster for ${articleId}`} className={`${input} w-72 max-w-full`} />
+ </label>
+ <label className="flex flex-col gap-0.5">
+ <span className="text-xs text-muted-foreground">Caption (optional)</span>
+ <input value={caption} onChange={(e) => setCaption(e.target.value)} aria-label={`caption for ${articleId}`} className="rounded border border-border bg-card px-2 py-1 text-sm w-72 max-w-full" />
+ </label>
+ </div>
+ <StreamActionLog
+ trigger={() => attachArticleVideoAction(articleId, { video: file, ...(poster.trim() ? { poster } : {}), ...(caption.trim() ? { caption } : {}) })}
+ cancelAction={cancelJobAction}
+ buttonLabel="Attach video"
+ runningLabel="Attaching…"
+ label={`Attach video to ${articleId}`}
+ disabled={!file.trim()}
+ />
+ </div>
+ </details>
+ );
+}
diff --git a/editor/app/sites/lib/articlesServer.ts b/editor/app/sites/lib/articlesServer.ts
@@ -25,7 +25,8 @@ import type { ReportExportsRow } from "./reportListServer";
// drafts, each read and validated as a site's report is (reportList.ts), with
// its audience; the articles' prepared media; their exports; the last jobs.
-export type ArticleRow = ReportRow & { audience: ReportAudience };
+// `video`: the article's own video (report.json `video.src`), or null.
+export type ArticleRow = ReportRow & { audience: ReportAudience; video: string | null };
// An index.json that cannot be read is the tab's error to show, not an empty
// list (lib/report/registry.ts readArticlesIndex).
@@ -44,7 +45,9 @@ export async function readArticleRows(paths: Paths): Promise<{ rows: ArticleRow[
);
const rows = reportRows(published, dirIds, reads).map((row) => {
const read = reads.get(row.id);
- return { ...row, audience: articleAudience(read?.ok ? (read.value as { audience?: unknown }) : null) };
+ const value = read?.ok ? (read.value as { audience?: unknown; video?: { src?: unknown } }) : null;
+ const video = typeof value?.video?.src === "string" ? value.video.src : null;
+ return { ...row, audience: articleAudience(value), video };
});
return { rows, indexError };
}
diff --git a/editor/app/sites/lib/attachVideoAction.ts b/editor/app/sites/lib/attachVideoAction.ts
@@ -0,0 +1,63 @@
+"use server";
+
+// "Attach video" on the Articles tab (release 32): an article's own video, as
+// `archilyzer reports attach-video --article <id> <video>` attaches it — the
+// file remuxed (an H.264 mp4 under the limit) or encoded to fit the publish
+// limit, written beside report.json as video.mp4 with a poster (given, kept,
+// or a frame of the video), and `video` set through the article registry
+// (patchArticle: locked, refused if it adds a problem). An `attach-report-video`
+// job on its own queue: an encode takes minutes.
+//
+// NOTHING BUT FUNCTIONS IS DECLARED HERE (a "use server" file).
+
+import path from "node:path";
+import { getPaths } from "yt-dlp-transcript-common/lib/paths";
+import { articleFile, patchArticle } from "yt-dlp-transcript-common/lib/report/registry";
+import { isReportId } from "yt-dlp-transcript-common/lib/report/schema";
+import { AttachVideoError, attachReportVideo } from "yt-dlp-transcript-common/publish/reportVideo";
+import { runManagedFunction, type StreamActionResult } from "yt-dlp-transcript-common/jobs/streamCommand";
+import { safeRevalidate } from "../../lib/safeRevalidate";
+
+const REPORT_VIDEO_QUEUE = "report-video";
+
+export async function attachArticleVideoAction(
+ articleId: string,
+ opts: { video: string; poster?: string; caption?: string },
+): Promise<StreamActionResult> {
+ if (!isReportId(articleId)) return { ok: false, error: `"${articleId}" is not an article id` };
+ const video = opts.video.trim();
+ const poster = opts.poster?.trim();
+ const caption = opts.caption?.trim();
+ if (!path.isAbsolute(video)) return { ok: false, error: "The video is an absolute path to a file on this machine" };
+ if (poster && !path.isAbsolute(poster)) return { ok: false, error: "The poster is an absolute path to an image on this machine" };
+ const paths = getPaths();
+ return runManagedFunction({
+ kind: "attach-report-video",
+ queueKey: REPORT_VIDEO_QUEUE,
+ paths,
+ fn: async (onLog) => {
+ try {
+ const done = await attachReportVideo({
+ reportFile: articleFile(paths, articleId),
+ setVideo: async (v) => {
+ if (!(await patchArticle(articleId, { video: v }, paths))) throw new AttachVideoError(`no article "${articleId}"`);
+ },
+ video,
+ ...(poster ? { poster } : {}),
+ ...(caption ? { caption } : {}),
+ ffmpegBin: paths.ffmpegBin,
+ ffprobeBin: paths.ffprobeBin,
+ onLog: (l) => onLog(`${l}\n`),
+ });
+ onLog(
+ `Attached to article ${articleId}: ${done.video.src} ` +
+ `(${done.mode === "remux" ? "remuxed" : `encoded, ${done.attempts} pass(es)`}, ${(done.bytes / (1024 * 1024)).toFixed(2)} MiB)\n`,
+ );
+ safeRevalidate(["/sites/articles"]);
+ } catch (err) {
+ const e = err as Error & { stderr?: string };
+ throw new Error(err instanceof AttachVideoError ? e.message : (e.stderr || e.message).trim().split("\n").slice(-3).join(" "));
+ }
+ },
+ });
+}