import { TranscriptConfig, TranscriptSegment, TranscriptResult, CaptionTrackInfo } from './types'; /** * Fetches YouTube video transcripts and caption metadata using the Innertube API. * * Can be used as an instance (with shared config) or via static/convenience methods. * * @example * ```typescript * // Instance usage with shared config * const yt = new YoutubeTranscript({ lang: 'en' }); * const transcript = await yt.fetchTranscript('dQw4w9WgXcQ'); * const languages = await yt.listLanguages('dQw4w9WgXcQ'); * * // Static method * const transcript = await YoutubeTranscript.fetchTranscript('dQw4w9WgXcQ', { lang: 'en' }); * * // Opt-in to video details * const { videoDetails, segments } = await YoutubeTranscript.fetchTranscript('dQw4w9WgXcQ', { * videoDetails: true, * }); * * // Convenience export * const transcript = await fetchTranscript('dQw4w9WgXcQ'); * const languages = await listLanguages('dQw4w9WgXcQ'); * ``` */ export declare class YoutubeTranscript { private config?; constructor(config?: TranscriptConfig | undefined); /** * Fetch caption tracks and the player response from the Innertube player API. * Shared logic used by both fetchTranscript and listLanguages. */ private _fetchCaptionTracks; /** * Extract VideoDetails from the Innertube player response. */ private _extractVideoDetails; /** * Fetch the transcript for a YouTube video. * * When `videoDetails` is set to `true` in the config, returns a {@link TranscriptResult} * containing both video metadata and transcript segments. Otherwise returns an array of * {@link TranscriptSegment} objects. * * **Note:** The instance method returns a union type because `videoDetails` is set at * construction time. For automatic type narrowing, use the static method or the * `fetchTranscript` convenience export instead. * * @param videoId - A YouTube video ID (11 characters) or full YouTube URL. * @returns An array of transcript segments, or a TranscriptResult if `videoDetails` is enabled. * @throws {@link YoutubeTranscriptInvalidVideoIdError} if the video ID/URL is invalid. * @throws {@link YoutubeTranscriptVideoUnavailableError} if the video is unavailable. * @throws {@link YoutubeTranscriptDisabledError} if transcripts are disabled. * @throws {@link YoutubeTranscriptNotAvailableError} if no transcript is available. * @throws {@link YoutubeTranscriptNotAvailableLanguageError} if the requested language is unavailable. * @throws {@link YoutubeTranscriptTooManyRequestError} if rate-limited by YouTube. */ fetchTranscript(videoId: string): Promise; /** * List available caption languages for a YouTube video. * * Queries the Innertube player API to discover what caption tracks exist, * without downloading any transcript data. * * @param videoId - A YouTube video ID (11 characters) or full YouTube URL. * @returns An array of available caption track info objects. * @throws {@link YoutubeTranscriptInvalidVideoIdError} if the video ID/URL is invalid. * @throws {@link YoutubeTranscriptVideoUnavailableError} if the video is unavailable. * @throws {@link YoutubeTranscriptDisabledError} if transcripts are disabled. * @throws {@link YoutubeTranscriptNotAvailableError} if no captions are available. * @throws {@link YoutubeTranscriptTooManyRequestError} if rate-limited by YouTube. * * @example * ```typescript * const yt = new YoutubeTranscript(); * const languages = await yt.listLanguages('dQw4w9WgXcQ'); * // [ * // { languageCode: 'en', languageName: 'English', isAutoGenerated: false }, * // { languageCode: 'es', languageName: 'Spanish (auto-generated)', isAutoGenerated: true }, * // ] * ``` */ listLanguages(videoId: string): Promise; /** * Static convenience method to fetch a transcript without creating an instance. * * @param videoId - A YouTube video ID (11 characters) or full YouTube URL. * @param config - Optional configuration options. * @returns An array of transcript segments, or a {@link TranscriptResult} when `videoDetails: true`. */ static fetchTranscript(videoId: string): Promise; static fetchTranscript(videoId: string, config: TranscriptConfig & { videoDetails: true; }): Promise; static fetchTranscript(videoId: string, config: TranscriptConfig): Promise; /** * Static convenience method to list available caption languages without creating an instance. * * @param videoId - A YouTube video ID (11 characters) or full YouTube URL. * @param config - Optional configuration options. * @returns An array of available caption track info objects. */ static listLanguages(videoId: string, config?: TranscriptConfig): Promise; } export type { CacheStrategy, CaptionTrackInfo, Thumbnail, TranscriptConfig, TranscriptResponse, TranscriptResult, TranscriptSegment, VideoDetails, FetchParams, } from './types'; export { InMemoryCache, FsCache } from './cache'; export { toSRT, toVTT, toPlainText } from './formatters'; export * from './errors'; /** * Convenience function to fetch a YouTube video transcript. * * @param videoId - A YouTube video ID (11 characters) or full YouTube URL. * @param config - Optional configuration options. * @returns An array of transcript segments, or a {@link TranscriptResult} when `videoDetails: true`. * * @example * ```typescript * import { fetchTranscript } from 'youtube-transcript-plus'; * * // Returns TranscriptSegment[] * const transcript = await fetchTranscript('dQw4w9WgXcQ'); * * // Returns TranscriptResult with video details * const { videoDetails, segments } = await fetchTranscript('dQw4w9WgXcQ', { * videoDetails: true, * }); * ``` */ export declare function fetchTranscript(videoId: string): Promise; export declare function fetchTranscript(videoId: string, config: TranscriptConfig & { videoDetails: true; }): Promise; export declare function fetchTranscript(videoId: string, config: TranscriptConfig): Promise; /** * Convenience function to list available caption languages for a YouTube video. * * @param videoId - A YouTube video ID (11 characters) or full YouTube URL. * @param config - Optional configuration options. * @returns An array of available caption track info objects. * * @example * ```typescript * import { listLanguages } from 'youtube-transcript-plus'; * const languages = await listLanguages('dQw4w9WgXcQ'); * ``` */ export declare const listLanguages: typeof YoutubeTranscript.listLanguages;