"use client"; import { useState, useTransition } from "react"; import type { SubtitleProvenance } from "yt-dlp-transcript-common/lib/subtitleProvenance"; import { setPrimaryTranscriptAction, } from "../../videoActions"; import { CANONICAL_VTT, TRANSCRIPT_PIN_FILENAME, WHISPER_FILENAME } from "./videoFiles"; const PROVENANCE_LABEL: Record = { asr: "YouTube auto-captions", manual: "manual captions", unknown: "unknown source", }; export function TranscriptSourceSection({ slug, videoId, vttTracks, primaryVtt, hasWhisper, vttProvenance, }: { slug: string; videoId: string; vttTracks: string[]; primaryVtt: string | null; hasWhisper: boolean; vttProvenance: Record; }) { const [pending, startTransition] = useTransition(); const [busyFile, setBusyFile] = useState(null); const [error, setError] = useState(null); const setPrimary = (filename: string) => { setError(null); setBusyFile(filename); startTransition(async () => { const res = await setPrimaryTranscriptAction(slug, videoId, filename); if (!res.ok) setError(res.error); setBusyFile(null); }); }; return (

Pick which subtitle track is this video's primary transcript. The chosen track is copied to {CANONICAL_VTT} and pinned there with {TRANSCRIPT_PIN_FILENAME}. Unpinned, the transcript is the first English track with text, transcript.en-orig.vtt{" "} first. Reversible: delete {TRANSCRIPT_PIN_FILENAME} in Files to fall back to that pick, or choose another track to switch.

{hasWhisper && (

A whisper transcript ({WHISPER_FILENAME}) is present and takes precedence over any VTT when indexing.

)}
    {vttTracks.map((name) => { const isPrimary = name === primaryVtt; return (
  • {name} {vttProvenance[name] && ( {PROVENANCE_LABEL[vttProvenance[name]]} )} {isPrimary && ( Primary )} {!isPrimary && ( )}
  • ); })}
{error && ( {error} )}
); }