/** * @typedef {'default' | 'mqdefault' | 'hqdefault' | 'sddefault' | 'maxresdefault'} YouTubeThumbnailQuality */ export type YouTubeThumbnailQuality = 'default' | 'mqdefault' | 'hqdefault' | 'sddefault' | 'maxresdefault'; export type YouTubeOEmbedResponse = { /** * - Video title. */ title: string; /** * - Channel display name. */ author_name: string; /** * - Channel URL. */ author_url: string; /** * - Resource type returned by the provider (e.g. "video"). */ type: string; /** * - oEmbed version. */ version: string; /** * - Always "YouTube". */ provider_name: string; /** * - Provider root URL. */ provider_url: string; /** * - Ready to use iframe markup. */ html: string; /** * - Suggested iframe width in pixels. */ width: number; /** * - Suggested iframe height in pixels. */ height: number; /** * - Thumbnail URL provided by the provider. */ thumbnail_url: string; /** * - Thumbnail width in pixels. */ thumbnail_width: number; /** * - Thumbnail height in pixels. */ thumbnail_height: number; }; export type FetchYouTubeOEmbedOptions = { /** * - Optional abort signal forwarded to fetch. */ signal?: AbortSignal; /** * - Injectable fetch implementation (useful for tests). */ fetchImpl?: typeof fetch; }; /** * Deeply validates a YouTube oEmbed payload. * @param {unknown} payload - Raw value returned by `response.json()`. * @param {string} [context='assertYouTubeOEmbedResponse'] - Caller name used in error messages. * @returns {YouTubeOEmbedResponse} A brand new, fully validated object. * @throws {TypeError} If the payload or any of its properties has the wrong type. * @throws {RangeError} If a numeric property is not a positive integer. */ export declare function assertYouTubeOEmbedResponse(payload: unknown, context?: string): YouTubeOEmbedResponse; /** * Extracts a YouTube video id from a raw id or a full YouTube URL. * @param {string} input - Raw 11 character video id or a full YouTube URL. * @returns {string} The 11 character video id. * @throws {TypeError} If `input` is not a string. * @throws {RangeError} If `input` is empty or the host is not a YouTube host. * @throws {SyntaxError} If `input` is not a valid id nor a parseable URL containing an id. */ export declare function extractYouTubeVideoId(input: string): string; /** * Fetches the oEmbed metadata of a YouTube video. * @param {string} videoIdOrUrl - Raw 11 character video id or a full YouTube URL. * @param {FetchYouTubeOEmbedOptions} [options] - Optional fetch configuration. * @returns {Promise} The fully validated oEmbed payload. * @throws {TypeError} If `options` is not a plain object, if `options.signal` is not an `AbortSignal`, * if `options.fetchImpl` is not a function, or if the payload has a wrong type. * @throws {RangeError} If the payload contains an out of range numeric value. * @throws {Error} If the HTTP request fails or returns a non 2xx status. */ export declare function fetchYouTubeOEmbed(videoIdOrUrl: string, options?: FetchYouTubeOEmbedOptions): Promise; /** * Builds the thumbnail URL of a YouTube video without any network request. * @param {string} videoIdOrUrl - Raw 11 character video id or a full YouTube URL. * @param {YouTubeThumbnailQuality} [quality='hqdefault'] - Thumbnail resolution. * @returns {string} The thumbnail URL. * @throws {TypeError} If `quality` is not a string. * @throws {RangeError} If `quality` is not a supported thumbnail quality. */ export declare function getYouTubeThumbnailUrl(videoIdOrUrl: string, quality?: YouTubeThumbnailQuality): string; //# sourceMappingURL=youtube.d.mts.map