"use client"; // An X search channel's fields on the channel form (release 38): the query as // X's search box takes it, the days walked between, the window size and a // language. Posted as xSearch* fields; parseChannelForm refuses what the // channel cannot hold, with a sentence. "Never archive"'s hidden authors ride // along unchanged in a hidden field (they are edited on the channel page). import { useState } from "react"; import { xSearchFromUrl } from "yt-dlp-transcript-common/lib/xSearch/config"; import type { XSearchConfig } from "yt-dlp-transcript-common/lib/xSearch/config"; export function XSearchFields({ initial, derivedFrom, }: { // Edit: the stored search. Create: none — the query comes from the URL. initial?: XSearchConfig; derivedFrom?: string; }) { const fromUrl = derivedFrom ? xSearchFromUrl(derivedFrom) : null; const seed = initial ?? fromUrl ?? undefined; const [query, setQuery] = useState(seed?.query ?? ""); const [touched, setTouched] = useState(false); // Create mode follows the URL until the query is typed by hand. const shownQuery = !initial && !touched && fromUrl ? fromUrl.query : query; const sinceSeed = initial?.since ?? fromUrl?.since ?? ""; const untilSeed = initial?.until ?? fromUrl?.until ?? ""; return (
X search {initial?.exclude?.length ? ( ) : null}
A fetch searches back from Until (blank: today) to Since (blank: until a year of windows finds nothing), newest first, a window at a time; later fetches search the new days. Needs an X login. Never on a site.
); }