commit 4738ceb46039f988aa00e96d06a1a1448b5b9e21
parent 5669dbdec12854c6ac2c0a844416e6c60381fdf7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Wed, 11 Nov 2026 09:44:59 -0500
local media: ten more doors refuse a local record in one sentence
Review fix 5. Each door refuses a local media library channel and a local
recording before any job, with lib/localMedia.ts's sentence ("... with no
online source, so no clip can be fetched for it."), or its sibling for the
doors that read metadata ("... so its metadata cannot be read from one."),
never the generic "Could not determine the video URL":
- transcribe-one (both actions), prepare-playable (channel and ids),
fetch-chat (liveChatPlan, before its normalize/fresh branches), live-clip
(before the umtool checks);
- refresh-metadata (resolveRefreshTarget), metadata-scan (before the no-URL
line), browser-lookup (channel and ids): the metadata sentence;
- persist-videos, import-media (both branches, and the record it resolves to)
and attach-media (the channel and named items; a walk's held record linked
to a library original is the new plan class "local-media", never attached)
also refuse a record LINKED to a library original (its external-media.json,
checked with lstat so a malformed one refuses too):
controller/localMediaDoors.ts localMediaWriteRefusal.
A table-driven test drives all ten through their ops routes (21 cases: the
channel, the local recording, the linked record for the writers), checks the
sentence, that no job was queued and the linked record is unchanged; it
fails with the generic message when a guard is removed. Plus the attach
plan's local-media class.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat:
16 files changed, 228 insertions(+), 4 deletions(-)
diff --git a/common/controller/attachMedia.ts b/common/controller/attachMedia.ts
@@ -53,7 +53,8 @@
// in flight and removes its staging file.
import path from "node:path";
-import { appendFile, mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
+import { appendFile, lstat, mkdir, readFile, readdir, rm, stat } from "node:fs/promises";
+import { EXTERNAL_MEDIA_FILENAME } from "../lib/localMedia";
import { createWriteStream } from "node:fs";
import { pipeline } from "node:stream/promises";
import { Transform, type TransformCallback } from "node:stream";
@@ -441,12 +442,18 @@ export async function attachMedia(opts: AttachMediaOptions): Promise<AttachMedia
pointers.set(id, p);
}
}
+ // Held records linked to a local media library original: never attached.
+ const localMedia = new Set<string>();
+ for (const id of held) {
+ if (await lstat(path.join(dataDir, id, EXTERNAL_MEDIA_FILENAME)).then(() => true, () => false)) localMedia.add(id);
+ }
const folders = groupArchiveFolders(source.files);
const plan = planAttach({
folders,
held,
attached,
+ localMedia,
...(opts.createRecords ? { createRecords: true } : {}),
...(opts.replace ? { replace: true } : {}),
...(match ? { match } : {}),
diff --git a/common/controller/browserLookupJob.ts b/common/controller/browserLookupJob.ts
@@ -21,6 +21,7 @@
// The job's log ends with `summary: {json}` — the per-video statuses and the
// listing's counts — for the UI to read back into sentences.
+import { localMediaMetadataRefusal } from "../lib/localMedia";
import path from "node:path";
import { assertChannelTextReadable } from "../lib/channelMedia";
import type { ChannelConfig } from "../lib/channelConfig";
@@ -77,6 +78,11 @@ export async function runBrowserLookupJob(opts: BrowserLookupJobOpts): Promise<S
}
const bad = ids.filter((id) => !isVideoIdSegment(id));
if (bad.length) return { ok: false, error: `Not a video id: ${bad.join(", ")}.` };
+ // A local media library channel or a local recording (review fix 5).
+ for (const id of [undefined, ...ids]) {
+ const localRefusal = localMediaMetadataRefusal(slug, channelConfig, id);
+ if (localRefusal) return { ok: false, error: localRefusal };
+ }
if (opts.listing) {
const refusal = browserListingRefusal(channelConfig);
if (refusal) return { ok: false, error: refusal };
diff --git a/common/controller/fetchLiveChat.ts b/common/controller/fetchLiveChat.ts
@@ -30,6 +30,7 @@
// `needsMedia` (jobs/jobKinds.ts): it WRITES the raw replay, which is a
// tierable big file, and the normalizer moves it into the channel's media/.
+import { localMediaFetchRefusal } from "../lib/localMedia";
import path from "node:path";
import { readFile, readdir, stat } from "node:fs/promises";
import {
@@ -112,6 +113,9 @@ export async function liveChatPlan(
}
const videoDir = path.join(paths.channelsDir, slug, "data", videoId);
if (!(await isDirectory(videoDir))) return { kind: "refused", error: notFetchedRefusal(videoId, slug) };
+ // A local media record has no chat to fetch (review fix 5), before any branch.
+ const localRefusal = localMediaFetchRefusal(slug, config, videoId);
+ if (localRefusal) return { kind: "refused", error: localRefusal };
const fresh = await isLiveChatCuesFresh(videoDir);
if (fresh.fresh) return { kind: "fresh", cuesPath: fresh.cuesPath };
const entries = await readdir(videoDir).catch(() => [] as string[]);
diff --git a/common/controller/importMedia.ts b/common/controller/importMedia.ts
@@ -28,6 +28,7 @@
// multi-GB copy never holds a platform's download queue. `needsMedia`: it
// writes the container and the audio.
+import { localMediaWriteRefusal } from "./localMediaDoors";
import path from "node:path";
import { mkdir, readdir, rm, stat } from "node:fs/promises";
import type { ChannelConfig } from "../lib/channelConfig";
@@ -310,6 +311,10 @@ export async function runImportMediaJob(opts: ImportMediaJobOpts): Promise<Strea
}
const target = await resolveImportTarget(paths, req);
if ("error" in target) return { ok: false, error: target.error, ...(target.info ? { info: true } : {}) };
+ // The record it would land in: never a local recording, a local library
+ // channel's, or one linked to a library original (review fix 5).
+ const localRefusal = await localMediaWriteRefusal(paths, req.slug, opts.channelConfig, target.id);
+ if (localRefusal) return { ok: false, error: localRefusal };
if (target.kind === "url" && !target.exists && !req.dryRun) {
const held = await heldPlatformRefusal(target.platform, "The metadata fetch", paths);
if (held) return { ok: false, info: true, error: held };
diff --git a/common/controller/localMediaDoors.ts b/common/controller/localMediaDoors.ts
@@ -0,0 +1,25 @@
+import path from "node:path";
+import { lstat } from "node:fs/promises";
+import type { Paths } from "../lib/paths";
+import { EXTERNAL_MEDIA_FILENAME, localMediaFetchRefusal } from "../lib/localMedia";
+
+// THE DOORS THAT WRITE MEDIA INTO A RECORD (import-media, attach-media; review
+// fix 5): besides a local library channel or a local recording
+// (localMediaFetchRefusal's sentence), a record LINKED to a library original —
+// one with `external-media.json`, a provider id included — is refused: its
+// video is the library's, never a copy in the saved-video store. `lstat`, not
+// the sidecar's loader: a malformed reference must refuse too.
+export async function localMediaWriteRefusal(
+ paths: Pick<Paths, "channelsDir">,
+ slug: string,
+ config: { localMedia?: unknown; url?: string | null } | null | undefined,
+ id?: string,
+): Promise<string | null> {
+ const fetch = localMediaFetchRefusal(slug, config, id);
+ if (fetch) return fetch;
+ if (!id || /[\\/]|^\.\.?$/.test(id)) return null;
+ const linked = await lstat(path.join(paths.channelsDir, slug, "data", id, EXTERNAL_MEDIA_FILENAME)).then(() => true, () => false);
+ return linked
+ ? `"${slug}/${id}" is linked to a local media library original (${EXTERNAL_MEDIA_FILENAME}), so no media is written into it.`
+ : null;
+}
diff --git a/common/controller/refreshVideoMetadata.ts b/common/controller/refreshVideoMetadata.ts
@@ -43,6 +43,7 @@
// The job around it (queue, kind, refusals) is refreshVideoMetadataJob.ts;
// this module needs no registry, so a test drives it with a stub runner.
+import { localMediaMetadataRefusal } from "../lib/localMedia";
import path from "node:path";
import { readFile, stat } from "node:fs/promises";
import {
@@ -123,6 +124,9 @@ export async function resolveRefreshTarget(
if (!(await isDirectory(videoDir))) {
return { ok: false, error: notFetchedRefusal(videoId, slug) };
}
+ // A local media record has no source to read metadata from (review fix 5).
+ const localRefusal = localMediaMetadataRefusal(slug, config, videoId);
+ if (localRefusal) return { ok: false, error: localRefusal };
const url = await findVideoSourceUrl(paths, slug, videoId, config);
if (!url) {
return {
diff --git a/common/lib/attachMediaPlan.test.ts b/common/lib/attachMediaPlan.test.ts
@@ -190,3 +190,22 @@ test("records: title from the folder name, date and description from description
assert.equal(other.webpage_url, undefined);
assert.equal(other.extractor, undefined);
});
+
+// lane/local-media review fix 5: a held record linked to a local media library
+// original (its external-media.json) is never attached, replace or not.
+test("plan: a held record linked to a local media library is class local-media, never attach", () => {
+ const folders = groupArchiveFolders(ARCHIVE);
+ for (const replace of [false, true]) {
+ const plan = planAttach({
+ folders,
+ held: new Set(["aaaaaaaaaaa"]),
+ attached: new Set(["aaaaaaaaaaa"]),
+ localMedia: new Set(["aaaaaaaaaaa"]),
+ ...(replace ? { replace: true } : {}),
+ });
+ const row = plan.rows.find((r) => r.id === "aaaaaaaaaaa")!;
+ assert.equal(row.class, "local-media");
+ assert.equal(countAttachRows(plan.rows)["local-media"], 1);
+ assert.equal(countAttachRows(plan.rows).attach, 0);
+ }
+});
diff --git a/common/lib/attachMediaPlan.ts b/common/lib/attachMediaPlan.ts
@@ -1,3 +1,4 @@
+import { LOCAL_RECORDING_ID_RE } from "./localMedia";
// WHICH FILE OF A LOCAL ARCHIVE IS WHICH VIDEO (release 21 D1).
//
// The pure half of `attach-media` (controller/attachMedia.ts): given the file
@@ -231,6 +232,10 @@ export const ATTACH_ROW_CLASSES = [
"unmatched",
// More than one video file for one id: name the file with `items`.
"ambiguous",
+ // A held record linked to a local media library original (its
+ // `external-media.json`), or a local recording: never attached — its video
+ // is the library's (lane/local-media review fix 5).
+ "local-media",
] as const;
export type AttachRowClass = (typeof ATTACH_ROW_CLASSES)[number];
@@ -261,6 +266,8 @@ export function planAttach(opts: {
folders: readonly ArchiveFolder[];
held: ReadonlySet<string>;
attached: ReadonlySet<string>;
+ // Held records linked to a local media library original (class "local-media").
+ localMedia?: ReadonlySet<string>;
createRecords?: boolean;
replace?: boolean;
match?: RegExp;
@@ -270,6 +277,9 @@ export function planAttach(opts: {
files?: readonly SourceFile[];
}): AttachPlan {
const classify = (id: string, media: SourceFile, folder: string, source?: ArchiveFolder): AttachRow => {
+ if (opts.localMedia?.has(id) || LOCAL_RECORDING_ID_RE.test(id)) {
+ return { class: "local-media", id, folder, media, ...(source ? { source } : {}) };
+ }
if (opts.held.has(id)) {
if (opts.attached.has(id) && !opts.replace) {
return { class: "already-attached", id, folder, media, ...(source ? { source } : {}) };
diff --git a/common/lib/localMedia.ts b/common/lib/localMedia.ts
@@ -59,11 +59,30 @@ export function localMediaFetchRefusal(
config: { localMedia?: unknown; url?: string | null } | null | undefined,
id?: string,
): string | null {
+ const who = localMediaSubject(slug, config, id);
+ return who ? `${who} with no online source, so no clip can be fetched for it.` : null;
+}
+
+// The same rule for the doors that READ METADATA from the source (refresh
+// metadata, the metadata scan, the browser lookup): a sibling sentence.
+export function localMediaMetadataRefusal(
+ slug: string,
+ config: { localMedia?: unknown; url?: string | null } | null | undefined,
+ id?: string,
+): string | null {
+ const who = localMediaSubject(slug, config, id);
+ return who ? `${who} with no online source, so its metadata cannot be read from one.` : null;
+}
+
+function localMediaSubject(
+ slug: string,
+ config: { localMedia?: unknown; url?: string | null } | null | undefined,
+ id?: string,
+): string | null {
const localChannel = !!config?.localMedia && !config.url?.trim();
const localRecord = typeof id === "string" && LOCAL_RECORDING_ID_RE.test(id);
if (!localChannel && !localRecord) return null;
- return `${localRecord ? `"${id}" is a local recording` : `"${slug}" is a local media library channel`}` +
- " with no online source, so no clip can be fetched for it.";
+ return localRecord ? `"${id}" is a local recording` : `"${slug}" is a local media library channel`;
}
// A record of a local media library's own (platform "local", or its
diff --git a/editor/app/api/ops/_localMediaDoors.test.ts b/editor/app/api/ops/_localMediaDoors.test.ts
@@ -0,0 +1,86 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import { mkdir, readdir, writeFile } from "node:fs/promises";
+import path from "node:path";
+import { callPost, setupOpsCorpus } from "./_testCorpus";
+
+// Run with:
+// pnpm -C editor exec tsx --test "app/api/ops/_localMediaDoors.test.ts"
+//
+// lane/local-media review fix 5: every door that would fetch, transcribe,
+// persist or write media refuses a local media library channel and a local
+// recording with lib/localMedia.ts's ONE sentence ("... with no online source,
+// so no clip can be fetched for it."), or its sibling for the metadata doors
+// ("... so its metadata cannot be read from one."), never a generic empty-URL
+// failure; and attach-media / import-media refuse a record linked to a library
+// original (external-media.json). Through each ops route; no job is queued and
+// no record changes.
+
+const corpus = await setupOpsCorpus(null);
+test.after(() => corpus.cleanup());
+const route = async (name: string) => (await import(`./${name}/route`)).POST;
+
+const LOCAL = "local-" + "e".repeat(32);
+const lib = { sourceId: "library-1", directory: path.join(corpus.root, "library") };
+await mkdir(lib.directory, { recursive: true });
+await corpus.writeChannelConfig("library", { name: "Library", handling: "youtube", url: undefined, sourceKind: "video", localMedia: lib });
+await corpus.writeChannelConfig("hybrid", { name: "Hybrid", handling: "youtube", url: "https://www.youtube.com/@hybrid", platform: "youtube", localMedia: lib });
+const record = async (slug: string, id: string, meta: unknown, extra: Record<string, string> = {}) => {
+ const dir = path.join(corpus.transcripts, "channels", slug, "data", id);
+ await mkdir(dir, { recursive: true });
+ await writeFile(path.join(dir, "metadata.info.json"), JSON.stringify(meta));
+ await writeFile(path.join(dir, "transcript.en.vtt"), "WEBVTT\n\n00:00:01.000 --> 00:00:02.000\nA cue\n");
+ for (const [name, body] of Object.entries(extra)) await writeFile(path.join(dir, name), body);
+};
+await record("library", "aaaaaaaaaaa", { id: "aaaaaaaaaaa", title: "Provider", upload_date: "20200101", webpage_url: "https://www.youtube.com/watch?v=aaaaaaaaaaa" });
+await record("hybrid", LOCAL, { id: LOCAL, title: "Talk", local_recording: { version: 1, titleSource: "filename", inspection: "manual", durationSource: "unknown" } });
+await record("hybrid", "linkedrec01", { id: "linkedrec01", title: "Linked", upload_date: "20200101", webpage_url: "https://www.youtube.com/watch?v=linkedrec01" },
+ { "external-media.json": JSON.stringify({ version: 1, kind: "external", sourceId: "library-1", relativePath: "linked.mp4" }) });
+const FILE = path.join(corpus.root, "a-file.mp4");
+await writeFile(FILE, "not really a video");
+
+const FETCH = /with no online source, so no clip can be fetched for it\.$/;
+const METADATA = /with no online source, so its metadata cannot be read from one\.$/;
+const LINKED = /^"hybrid\/linkedrec01" is linked to a local media library original \(external-media\.json\), so no media is written into it\.$/;
+const CHANNEL = /^"library" is a local media library channel /;
+const RECORD = new RegExp(`^"${LOCAL}" is a local recording `);
+
+const DOORS: Array<[string, Record<string, unknown>, RegExp, RegExp]> = [
+ ["transcribe-one", { slug: "library", id: "aaaaaaaaaaa" }, CHANNEL, FETCH],
+ ["transcribe-one", { slug: "hybrid", id: LOCAL }, RECORD, FETCH],
+ ["prepare-playable", { slug: "library" }, CHANNEL, FETCH],
+ ["prepare-playable", { slug: "hybrid", ids: [LOCAL] }, RECORD, FETCH],
+ ["persist-videos", { items: [{ slug: "library", id: "aaaaaaaaaaa" }] }, CHANNEL, FETCH],
+ ["persist-videos", { items: [{ slug: "hybrid", id: LOCAL }] }, RECORD, FETCH],
+ ["refresh-metadata", { slug: "library", id: "aaaaaaaaaaa" }, CHANNEL, METADATA],
+ ["refresh-metadata", { slug: "hybrid", id: LOCAL }, RECORD, METADATA],
+ ["metadata-scan", { slug: "library" }, CHANNEL, METADATA],
+ ["browser-lookup", { slug: "library", listing: true }, CHANNEL, METADATA],
+ ["browser-lookup", { slug: "hybrid", ids: [LOCAL] }, RECORD, METADATA],
+ ["fetch-chat", { slug: "library", id: "aaaaaaaaaaa" }, CHANNEL, FETCH],
+ ["fetch-chat", { slug: "hybrid", id: LOCAL }, RECORD, FETCH],
+ ["live-clip", { slug: "library", id: "aaaaaaaaaaa", start: 1, end: 5 }, CHANNEL, FETCH],
+ ["live-clip", { slug: "hybrid", id: LOCAL, start: 1, end: 5 }, RECORD, FETCH],
+ ["import-media", { slug: "library", path: FILE, id: "aaaaaaaaaaa" }, CHANNEL, FETCH],
+ ["import-media", { slug: "hybrid", path: FILE, id: LOCAL }, RECORD, FETCH],
+ ["import-media", { slug: "hybrid", path: FILE, id: "linkedrec01" }, LINKED, LINKED],
+ ["attach-media", { slug: "library", source: corpus.root }, CHANNEL, FETCH],
+ ["attach-media", { slug: "hybrid", source: corpus.root, items: [{ id: LOCAL, path: "a-file.mp4" }] }, RECORD, FETCH],
+ ["attach-media", { slug: "hybrid", source: corpus.root, items: [{ id: "linkedrec01", path: "a-file.mp4" }] }, LINKED, LINKED],
+];
+
+test("every door refuses a local library channel, a local recording and (writers) a linked record, with the one sentence", async () => {
+ const before = await corpus.listJobIds();
+ const dirs = async () => (await readdir(path.join(corpus.transcripts, "channels", "hybrid", "data", "linkedrec01"))).sort();
+ const linkedBefore = await dirs();
+ for (const [name, body, who, sentence] of DOORS) {
+ const r = await callPost(await route(name), body);
+ const label = `${name} ${JSON.stringify(body)} -> ${r.status} ${JSON.stringify(r.body)}`;
+ assert.equal(r.body.ok, false, label);
+ assert.match(String(r.body.error), who, label);
+ assert.match(String(r.body.error), sentence, label);
+ assert.doesNotMatch(String(r.body.error), /Could not determine the video URL|no `url` configured/, label);
+ }
+ assert.deepEqual(await corpus.listJobIds(), before, "no job was queued");
+ assert.deepEqual(await dirs(), linkedBefore, "the linked record is unchanged");
+});
diff --git a/editor/app/channels/[slug]/attachMediaActions.ts b/editor/app/channels/[slug]/attachMediaActions.ts
@@ -1,5 +1,6 @@
"use server";
+import { localMediaWriteRefusal } from "yt-dlp-transcript-common/controller/localMediaDoors";
import path from "node:path";
import { safeRevalidate } from "../../lib/safeRevalidate";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
@@ -41,6 +42,13 @@ export async function attachMediaAction(
if (!channelConfig) {
return { ok: false, error: `Channel "${slug}" not found` };
}
+ // A local media library channel, or a named item that is a local recording or
+ // linked to a library original (review fix 5); a walk's ids are refused in
+ // the job (controller/attachMedia.ts, class "local-media").
+ for (const id of [undefined, ...(opts.items ?? []).map((i) => i.id)]) {
+ const localRefusal = await localMediaWriteRefusal(paths, slug, channelConfig, id);
+ if (localRefusal) return { ok: false, error: localRefusal };
+ }
const source = opts.source.trim();
if (!path.isAbsolute(source)) {
return { ok: false, error: `"source" must be an absolute path (a directory, a .zip or a .7z)` };
diff --git a/editor/app/channels/[slug]/liveMediaActions.ts b/editor/app/channels/[slug]/liveMediaActions.ts
@@ -22,6 +22,8 @@
//
// NOTHING BUT FUNCTIONS IS DECLARED HERE (a "use server" file).
+import { localMediaWriteRefusal } from "yt-dlp-transcript-common/controller/localMediaDoors";
+import { localMediaFetchRefusal } from "yt-dlp-transcript-common/lib/localMedia";
import { stat } from "node:fs/promises";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import { getSettings } from "yt-dlp-transcript-common/lib/settings";
@@ -62,6 +64,10 @@ export async function importMediaAction(body: Record<string, unknown>): Promise<
const paths = getPaths();
const config = await readChannelConfig(paths, req.slug);
if (!config) return { ok: false, error: `Channel "${req.slug}" not found` };
+ // Both branches (one file, or attach-media's walk): a local media library
+ // channel, a local recording, or a record linked to a library original.
+ const localRefusal = await localMediaWriteRefusal(paths, req.slug, config, req.id);
+ if (localRefusal) return { ok: false, error: localRefusal };
const st = await stat(req.path).catch(() => null);
if (!st) return { ok: false, error: `${req.path} is not there` };
if (isArchivePath(req.path, st.isDirectory())) {
@@ -150,7 +156,11 @@ export async function liveClipAction(body: Record<string, unknown>): Promise<Str
if (!parsed.ok) return parsed;
if (!isValidChannelSlug(parsed.value.slug)) return { ok: false, error: `"${parsed.value.slug}" is not a channel slug` };
const paths = getPaths();
- if (!(await readChannelConfig(paths, parsed.value.slug))) return { ok: false, error: `Channel "${parsed.value.slug}" not found` };
+ const config = await readChannelConfig(paths, parsed.value.slug);
+ if (!config) return { ok: false, error: `Channel "${parsed.value.slug}" not found` };
+ // Before the umtool checks: a local media record has no live source (review fix 5).
+ const localRefusal = localMediaFetchRefusal(parsed.value.slug, config, parsed.value.id);
+ if (localRefusal) return { ok: false, error: localRefusal };
return runLiveClipJob({ paths, request: parsed.value });
}
diff --git a/editor/app/channels/[slug]/persistActions.ts b/editor/app/channels/[slug]/persistActions.ts
@@ -1,5 +1,6 @@
"use server";
+import { localMediaWriteRefusal } from "yt-dlp-transcript-common/controller/localMediaDoors";
import { safeRevalidate } from "../../lib/safeRevalidate";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import { getSettings } from "yt-dlp-transcript-common/lib/settings";
@@ -161,6 +162,12 @@ export async function persistVideosAction(
const { items, dryRun, ...opts } = input;
if (items.length === 0) return { ok: false, error: "No videos to persist." };
const paths = getPaths();
+ // A local media library channel, a local recording, or a record linked to a
+ // library original has nothing to persist from a source (review fix 5).
+ for (const item of items) {
+ const localRefusal = await localMediaWriteRefusal(paths, item.slug, await readChannelConfig(paths, item.slug).catch(() => null), item.id);
+ if (localRefusal) return { ok: false, error: localRefusal };
+ }
const planned = await persistVideos({
paths,
items,
diff --git a/editor/app/channels/[slug]/pipelineActions.ts b/editor/app/channels/[slug]/pipelineActions.ts
@@ -1,5 +1,6 @@
"use server";
+import { localMediaMetadataRefusal } from "yt-dlp-transcript-common/lib/localMedia";
import { manualDownloadsRefusal } from "yt-dlp-transcript-common/lib/manualDownloads";
import { isSocialChannel } from "yt-dlp-transcript-common/lib/channelConfig";
import { fetchPostsAction } from "./socialActions";
@@ -445,6 +446,8 @@ export async function runMetadataScanAction(
if (!channelConfig) {
return { ok: false, error: `Channel "${slug}" not found` };
}
+ const localRefusal = localMediaMetadataRefusal(slug, channelConfig);
+ if (localRefusal) return { ok: false, error: localRefusal };
if (!channelConfig.url) {
return { ok: false, error: "Channel has no `url` configured" };
}
diff --git a/editor/app/channels/[slug]/playableActions.ts b/editor/app/channels/[slug]/playableActions.ts
@@ -1,5 +1,6 @@
"use server";
+import { localMediaFetchRefusal } from "yt-dlp-transcript-common/lib/localMedia";
import path from "node:path";
import { safeRevalidate } from "../../lib/safeRevalidate";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
@@ -27,6 +28,11 @@ export async function preparePlayableAction(
if (!channelConfig) {
return { ok: false, error: `Channel "${slug}" not found` };
}
+ // A local media library channel, or a local recording among the ids.
+ for (const id of [undefined, ...(opts.ids ?? [])]) {
+ const localRefusal = localMediaFetchRefusal(slug, channelConfig, id);
+ if (localRefusal) return { ok: false, error: localRefusal };
+ }
if (opts.root !== undefined && !path.isAbsolute(opts.root)) {
return { ok: false, error: `"root" must be an absolute path` };
}
diff --git a/editor/app/channels/[slug]/videos/[id]/videoActions.ts b/editor/app/channels/[slug]/videos/[id]/videoActions.ts
@@ -262,6 +262,9 @@ export async function transcribeOneAction(
): Promise<StreamActionResult> {
const r = await loadConfigOrError(slug);
if (!r.ok) return r;
+ // A local media record: nothing to transcribe from a source (slice 3's drafts).
+ const localRefusal = localMediaFetchRefusal(slug, r.config, videoId);
+ if (localRefusal) return { ok: false, error: localRefusal };
return queueTranscribeOne({
slug,
videoId,
@@ -723,6 +726,8 @@ export async function whisperVideoAction(
): Promise<WhisperVideoResult> {
const r = await loadConfigOrError(slug);
if (!r.ok) return r;
+ const localRefusal = localMediaFetchRefusal(slug, r.config, videoId);
+ if (localRefusal) return { ok: false, error: localRefusal };
const paths = getPaths();
const videoDir = videoDirOf(slug, videoId);
const audioFormat = r.config.audioFormat ?? "mp3";