Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 3f74d9fbe69076e2b4cbf544bae67bb31f06432e
parent 135519602c6a31627e42804a17e287c0e856cdd6
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri, 16 Oct 2026 17:05:16 -0400

channels: "Keep videos matching" on the Cleanup stage (keep-videos as a button)

A pattern over titles (and, ticked, descriptions), a note; Preview lists the
matches, "Keep them" — armed by a preview of the same pattern — sets the
do-not-clean marker through keepVideosAction, which only `pnpm ops
keep-videos` called.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Aeditor/app/channels/[slug]/components/KeepMatchingControl.tsx | 102+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Meditor/app/channels/[slug]/components/stages/CleanupStage.tsx | 2++
2 files changed, 104 insertions(+), 0 deletions(-)

diff --git a/editor/app/channels/[slug]/components/KeepMatchingControl.tsx b/editor/app/channels/[slug]/components/KeepMatchingControl.tsx @@ -0,0 +1,102 @@ +"use client"; + +import Link from "next/link"; +import { useEffect, useState, useTransition } from "react"; +import { Button } from "yt-dlp-transcript-common/components/ui/button"; +import type { KeepVideosResult } from "yt-dlp-transcript-common/controller/keepVideosMatching"; +import { keepVideosAction } from "../videos/[id]/videoActions"; + +// "Keep videos matching" (release 32; `pnpm ops keep-videos` before it): the +// do-not-clean marker on every video of the channel whose title (or +// description) matches a pattern — the cleanup sweeps then never delete their +// audio. Preview lists the matches; Keep is armed by a preview of the same +// pattern. +export function KeepMatchingControl({ slug }: { slug: string }) { + const [hydrated, setHydrated] = useState(false); + useEffect(() => setHydrated(true), []); + const [pattern, setPattern] = useState(""); + const [description, setDescription] = useState(false); + const [note, setNote] = useState(""); + const key = `${pattern}\u0000${description}`; + const [previewed, setPreviewed] = useState<string | null>(null); + const [result, setResult] = useState<KeepVideosResult | null>(null); + const [error, setError] = useState<string | null>(null); + const [pending, start] = useTransition(); + const go = (dryRun: boolean) => + start(async () => { + setError(null); + const res = await keepVideosAction({ + slug, + pattern, + fields: description ? ["title", "description"] : ["title"], + ...(note.trim() ? { note: note.trim() } : {}), + dryRun, + }); + if (!res.ok) { + setError(res.error); + setResult(null); + return; + } + setResult(res.result); + if (dryRun) setPreviewed(key); + }); + return ( + <div aria-label="keep videos matching" className="flex flex-col gap-2 rounded border border-border p-3"> + <h4 className="text-sm font-semibold">Keep videos matching</h4> + <div className="flex flex-wrap items-center gap-3 text-sm"> + <input + value={pattern} + onChange={(e) => setPattern(e.target.value)} + aria-label="keep pattern" + placeholder="pattern, e.g. interview|debate" + className="rounded border border-border bg-card px-2 py-1 text-sm font-mono w-72 max-w-full" + /> + <label className="flex items-center gap-2"> + <input type="checkbox" checked={description} onChange={(e) => setDescription(e.target.checked)} /> + Descriptions too + </label> + <input + value={note} + onChange={(e) => setNote(e.target.value)} + aria-label="keep note" + placeholder="note (optional)" + className="rounded border border-border bg-card px-2 py-1 text-sm w-56 max-w-full" + /> + </div> + <div className="flex gap-2"> + <Button type="button" size="sm" variant="outline" disabled={!hydrated || pending || !pattern.trim()} onClick={() => go(true)}> + Preview matches + </Button> + <Button type="button" size="sm" disabled={!hydrated || pending || previewed !== key} onClick={() => go(false)}> + Keep them + </Button> + </div> + {error && ( + <p role="alert" className="text-xs text-destructive"> + {error} + </p> + )} + {result && ( + <div className="flex flex-col gap-1 text-xs" aria-label="keep matches"> + <p role="status"> + {result.matched.length} match{result.matched.length === 1 ? "" : "es"} of {result.considered} + {result.dryRun ? "" : `; ${result.marked} kept now`}, {result.alreadyKept} already kept + {result.notDownloaded.length > 0 && `, ${result.notDownloaded.length} not downloaded`} + {result.unscanned > 0 && `, ${result.unscanned} never scanned (not tested)`} + </p> + <ul className="max-h-48 overflow-auto"> + {result.matched.slice(0, 200).map((m) => ( + <li key={m.id}> + <Link href={`/channels/${slug}/videos/${m.id}`} className="font-mono underline"> + {m.id} + </Link>{" "} + {m.title} + {m.alreadyKept ? " (kept)" : m.marked ? " (kept now)" : ""} + </li> + ))} + </ul> + </div> + )} + </div> + ); +} diff --git a/editor/app/channels/[slug]/components/stages/CleanupStage.tsx b/editor/app/channels/[slug]/components/stages/CleanupStage.tsx @@ -1,6 +1,7 @@ "use client"; import { useState } from "react"; +import { KeepMatchingControl } from "../KeepMatchingControl"; import { StreamActionLog } from "yt-dlp-transcript-common/components/StreamActionLog"; import { formatBytes } from "yt-dlp-transcript-common/lib/format"; import { QueueControl } from "../../../../components/QueueControl"; @@ -68,6 +69,7 @@ export function CleanupStage({ const [cleanQueue, setCleanQueue] = useState(defaultQueueKey); return ( <div className="flex flex-col gap-6"> + <KeepMatchingControl slug={slug} /> {(keepLatest > 0 || savedCount > 0) && ( <RetentionSection slug={slug}