UNPKG

t-youtube-transcript-fetcher

Version:

An enhanced TypeScript library for fetching YouTube transcripts with proxy support (based on youtube-transcript)

50 lines (49 loc) 1.48 kB
import { TranscriptConfig, TranscriptSegment } from './types.js'; /** * Service class for fetching YouTube video transcripts */ export declare class YoutubeTranscript { /** * Fetches the transcript for a YouTube video * @param videoId Video URL or ID * @param config Configuration options * @returns Array of transcript segments */ static fetchTranscript(videoId: string, config?: TranscriptConfig): Promise<TranscriptSegment[]>; /** * Creates fetch options with proxy configuration if provided */ private static getFetchOptions; /** * Fetches the video page content */ private static fetchVideoPage; /** * Extracts and validates captions data from the video page */ private static parseCaptionsData; /** * Extracts captions JSON data from the page content */ private static extractCaptionsJson; /** * Handles various error cases from the video page */ private static handlePageErrors; /** * Gets the URL for the transcript in the requested language */ private static getTranscriptUrl; /** * Validates that the requested language is available */ private static validateLanguageAvailability; /** * Fetches and parses the transcript XML */ private static fetchAndParseTranscript; /** * Extracts the video ID from either a full URL or direct ID */ private static retrieveVideoId; }