/** * YouTube transcript fetcher * * Strategy (matches what youtube-transcript, youtube-transcript-api, etc. use): * 1. Fetch the YouTube watch page to extract INNERTUBE_API_KEY * 2. POST to the innertube /player endpoint with ANDROID client context * — ANDROID client timedtext URLs work server-side without a PO token * — WEB client URLs may require a PO token (&exp=xpe) which needs BotGuard JS * 3. Fetch the signed timedtext URL from the innertube response */ import type { FetchOptions, Transcript, TranscriptSegment } from '../types'; export interface CaptionTrack { baseUrl: string; languageCode: string; kind?: string; name?: { simpleText?: string; }; } interface TimedTextEvent { segs?: Array<{ utf8?: string; }>; tStartMs?: number; dDurationMs?: number; } interface TimedTextResponse { events?: TimedTextEvent[]; } /** * Extract video ID from various YouTube URL formats */ export declare function extractVideoId(input: string): string | null; /** * Extract INNERTUBE_API_KEY from the YouTube watch page HTML. * This key is required for the innertube API endpoint. */ export declare function extractApiKey(html: string): string | null; /** * Extract captionTracks from ytInitialPlayerResponse embedded in the HTML page. * Used as a fallback when the innertube API call fails. */ export declare function extractTracksFromHTML(html: string): CaptionTrack[] | null; /** * Parse a timedtext json3 response into transcript segments. * Pure function — given the parsed JSON, returns segments. */ export declare function parseTimedTextEvents(data: TimedTextResponse): TranscriptSegment[]; /** * Select the best caption track based on language preferences. * Pure function — returns null when no track is suitable. */ export declare function selectCaptionTrack(tracks: CaptionTrack[], preferredLanguages: string[], includeAutoGenerated: boolean): CaptionTrack | null; /** * Fetch available caption tracks for a video */ export declare function fetchVideoInfo(videoId: string, options?: FetchOptions): Promise; /** * Fetch transcript for a single video */ export declare function fetchTranscript(videoId: string, options?: FetchOptions): Promise; export {}; //# sourceMappingURL=fetcher.d.ts.map