Archilyzer · Source

archilyzer

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

commit 0427c2bec2a574b18b064d028a25950a04474397
parent 899fe1d435b57015f7e9a3016041e11a6773a37a
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 19 Nov 2026 00:30:13 -0500

clip windows: review 4 C -- the full-address rule is for a local channel's webpageUrl; a remote-only channel's is parsed and written back, as before

The first cut refused a remote-only channel's "https:host/…" ask, which
recordPage parses and writes back (ops fetch-windows route.remote test). The
check now runs where the channel is known: in the single window's route after
the remote-only branch, and in the batch's plan after the config is read; a
job handed items checks every one (they were planned). The helpers live in
lib/clipWindow.ts (fetchWindowsAction is a "use server" module).

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mcommon/lib/clipWindow.ts | 13+++++++++++++
Meditor/CHANGELOG.md | 4++--
Meditor/app/api/media/fetch-window/route.ts | 17++++++++---------
Meditor/app/channels/[slug]/videos/fetchWindowsAction.ts | 22+++++++++++++++-------
Mplans/x-trending.md | 7++++---
5 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/common/lib/clipWindow.ts b/common/lib/clipWindow.ts @@ -446,3 +446,16 @@ export function tightestClipWindow<T extends ClipWindowSpan>( } return best; } + +// A CALLER'S PAGE ADDRESS FOR A LOCAL CHANNEL IS A FULL http(s) ADDRESS +// (review 4 C; POST /api/media/fetch-window, a fetch-windows item): one written +// without its scheme ("x.com/…") is read by no rule the same way twice. A +// remote-only channel's is parsed and written back instead (lib/remoteArchives.ts +// recordPage). +export function isFullPageAddress(raw: string): boolean { + return /^https?:\/\//i.test(raw.trim()); +} + +export function pageAddressRefusal(raw: string): string { + return `webpageUrl must be an http(s) address (https://…): ${JSON.stringify(raw.trim())} is not one. Nothing was asked.`; +} diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md @@ -28,8 +28,8 @@ platform, is not X's. A window cut from a saved copy that is gone by the time it runs fails with a sentence and asks X nothing. A `t.co` link is X's, and so are X's media hosts (`video.twimg.com`, `pbs.twimg.com`). - **Importing a file by an X page's address runs on X's queue on any channel**, `t.co` links included, and - counts. A `webpageUrl` given to `POST /api/media/fetch-window` or to a fetch-windows item must be a full - `http(s)://` address; one without its scheme is refused before anything is asked. + counts. A `webpageUrl` given for a local channel to `POST /api/media/fetch-window` or to a fetch-windows item + must be a full `http(s)://` address; one without its scheme is refused before anything is asked. - The scheduler queues no more X syncs than the cap has starts left; the others wait for a later tick instead of each ending deferred. - An X channel's jobs that never ask X run on their own queues again: a transcription (whisper-video's hand-off diff --git a/editor/app/api/media/fetch-window/route.ts b/editor/app/api/media/fetch-window/route.ts @@ -6,6 +6,8 @@ import { MAX_FETCH_MAX_HEIGHT, MIN_FETCH_MAX_HEIGHT, isFetchMaxHeight, + isFullPageAddress, + pageAddressRefusal, } from "yt-dlp-transcript-common/lib/clipWindow"; import { sourceVideoQualityForMaxHeight } from "yt-dlp-transcript-common/ytdlp/downloadFormat"; import { @@ -214,15 +216,6 @@ export async function POST(request: Request) { // its whole recording — `full`, or a window on a whole-recording platform — // is refused with the recording's size (409) unless `allowWholeRecording`. let webpageUrl = str(body.webpageUrl); - // A CALLER'S PAGE ADDRESS IS A FULL http(s) ADDRESS (review 4 C), before the - // cache, the archive or any job: one written without its scheme ("x.com/…") - // is read by no rule the same way twice. - if (webpageUrl !== undefined && !/^https?:\/\//i.test(webpageUrl)) { - return NextResponse.json( - { error: `webpageUrl must be an http(s) address (https://…): ${JSON.stringify(webpageUrl)} is not one. Nothing was asked.` }, - { status: 400 }, - ); - } { const paths = getPaths(); const getJson = cachedArchiveGetJson(); @@ -269,6 +262,12 @@ export async function POST(request: Request) { { status: 409 }, ); } + } else if (webpageUrl !== undefined && !isFullPageAddress(webpageUrl)) { + // A LOCAL CHANNEL'S PAGE ADDRESS, from the caller, is a full http(s) + // address (review 4 C), before the cache or any job: one written + // without its scheme ("x.com/…") is read by no rule the same way twice. + // (A remote-only channel's is parsed and written back above.) + return NextResponse.json({ error: pageAddressRefusal(webpageUrl) }, { status: 400 }); } } diff --git a/editor/app/channels/[slug]/videos/fetchWindowsAction.ts b/editor/app/channels/[slug]/videos/fetchWindowsAction.ts @@ -1,6 +1,7 @@ "use server"; import { localMediaFetchRefusal } from "yt-dlp-transcript-common/lib/localMedia"; +import { isFullPageAddress, pageAddressRefusal } from "yt-dlp-transcript-common/lib/clipWindow"; import path from "node:path"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; @@ -211,15 +212,17 @@ function itemProblem(item: FetchWindowsItem): string | null { `(at most ${MAX_CLIP_WINDOW_SECONDS}s, from < to, from >= 0)` ); } - // A CALLER'S PAGE ADDRESS IS A FULL http(s) ADDRESS (review 4 C): one - // written without its scheme ("x.com/…") is read by no rule the same way twice. - const page = typeof item.webpageUrl === "string" ? item.webpageUrl.trim() : ""; - if (page && !/^https?:\/\//i.test(page)) { - return `webpageUrl must be an http(s) address (https://…): ${JSON.stringify(page)} is not one. Nothing was asked.`; - } return null; } +// A local channel's page address from the caller (lib/clipWindow.ts +// isFullPageAddress, review 4 C). Every item a job is handed has been planned, +// so its address is a checked one. +function pageAddressProblem(item: FetchWindowsItem): string | null { + const page = typeof item.webpageUrl === "string" ? item.webpageUrl.trim() : ""; + return page && !isFullPageAddress(page) ? pageAddressRefusal(page) : null; +} + // Validate, answer the cache, resolve every URL and group by queue. Nothing is // started; nothing touches the network. async function planFetchWindows( @@ -307,6 +310,11 @@ async function planFetchWindows( unresolved.push({ item, error: localRefusal }); continue; } + const pageRefusal = isRemoteOnlyChannel(config) ? null : pageAddressProblem(item); + if (pageRefusal) { + unresolved.push({ item, error: pageRefusal }); + continue; + } // The item names a RECORD; its directory may be another id — a Twitch // record's v<n> is data/<n>/ (release 23 F1). The item keeps its id. const dirId = await resolveVideoDirId(paths.channelsDir, item.slug, item.id, { @@ -546,7 +554,7 @@ export async function fetchWindowsJobAction(req: { }; } for (const item of req.items) { - const problem = itemProblem(item); + const problem = itemProblem(item) ?? pageAddressProblem(item); if (problem) return { ok: false, error: `${fetchWindowsItemLabel(item)}: ${problem}` }; } const paths = getPaths(); diff --git a/plans/x-trending.md b/plans/x-trending.md @@ -514,9 +514,10 @@ These are rulings, not reasons. guards read it from `askParams`, because import-media has no replay descriptor. The metadata pass asks `xJobContextRefusal` before it hands an X address to yt-dlp. - **X'S ADDRESSES BY THE HOST ALONE:** lowercased, a trailing dot dropped. `twimg.com` and its subdomains are X's. - An address written without a scheme is X's when its first segment is an X host. A caller's `webpageUrl` at - `POST /api/media/fetch-window`, or on a fetch-windows item, must begin `http://` or `https://`. Otherwise it - is refused (400, or the item's problem). + An address written without a scheme is X's when its first segment is an X host. A caller's `webpageUrl` for a + local channel, at `POST /api/media/fetch-window` or on a fetch-windows item, must begin `http://` or + `https://`. Otherwise it is refused (400, or the item's problem). A remote-only channel's is parsed and + written back, as before. - **AN X JOB RUNNING WITH NO START RECORDED TAKES THE CAP'S ROOM** in the scheduler's count of X jobs waiting, as a queued one does.