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M,GAAU,MACpG,CAeA,MAAA,CAAO,EAAO,EAAQ,EAAG,EAAU,CAAC,GAChC,OAAO,KAAK,QAAQ,aAAa,UAAU,UAAU,OAAQ,EAAO,OAAO,OAAO,EAAS,CAAE,EAAG,EAAO,KAAM,UAAU,MAAM,UACxH,MAAK,GAAU,EAAO,KAAI,GACnB,EAAK,GAAG,OAAS,UAAU,MAAM,MAAc,IAAI,MAAM,KAAM,GAC/D,EAAK,GAAG,OAAS,UAAU,MAAM,SAAiB,IAAI,SAAS,KAAM,GACrE,EAAK,GAAG,OAAS,UAAU,MAAM,QAAgB,IAAI,QAAQ,KAAM,GAChE,QAEnB,CAeA,YAAA,CAAa,EAAO,EAAQ,EAAG,EAAU,CAAC,GACtC,OAAO,KAAK,OAAO,EAAO,EAAO,OAAO,OAAO,EAAS,CAAE,KAAM,UACpE,CAeA,eAAA,CAAgB,EAAO,EAAQ,EAAG,EAAU,CAAC,GACzC,OAAO,KAAK,OAAO,EAAO,EAAO,OAAO,OAAO,EAAS,CAAE,KAAM,aACpE,CAeA,cAAA,CAAe,EAAO,EAAQ,EAAG,EAAU,CAAC,GACxC,OAAO,KAAK,OAAO,EAAO,EAAO,OAAO,OAAO,EAAS,CAAE,KAAM,YACpE,EAGJ,QAAQ,MAAQ,MAChB,QAAQ,SAAW,SACnB,QAAQ,QAAU,QAClB,QAAQ,KAAO,KAEf,OAAO,QAAU","file":"/npm/simple-youtube-api@5.2.1/src/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/simple-youtube-api@5.2.1/src/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const Request = require('./Request');\n\nconst Video = require('./structures/Video');\nconst Playlist = require('./structures/Playlist');\nconst Channel = require('./structures/Channel');\n\nconst util = require('./util');\nconst Constants = require('./util/Constants');\n\n/**\n * Information about a thumbnail\n * @typedef {Object} Thumbnail\n * @property {string} url The URL of this thumbnail\n * @property {number} width The width of this thumbnail\n * @property {number} height The height of this thumbnail\n */\n\n/**\n * The YouTube API module\n */\nclass YouTube {\n    /**\n     * @param {string} key The YouTube Data API v3 key to use\n     */\n    constructor(key) {\n        if (typeof key !== 'string') throw new Error('The YouTube API key you provided was not a string.');\n        /**\n         * The YouTube Data API v3 key\n         * @type {?string}\n         */\n        this.key = key;\n        Object.defineProperty(this, 'key', { enumerable: false });\n\n        this.request = new Request(this);\n    }\n\n    /**\n     * Make a request to the YouTube API\n     * @param {string} endpoint The endpoint of the API\n     * @param {Object} qs The query string options\n     * @returns {Promise<Object>}\n     */\n\n    /**\n     * Get a video by URL or ID\n     * @param {string} url The video URL or ID\n     * @param {Object} [options = {}] Options to request with the video.\n     * @returns {Promise<?Video>}\n     * @example\n     * API.getVideo('https://www.youtube.com/watch?v=dQw4w9WgXcQ')\n     *  .then(video => {\n     *    if (video) console.log(`The video's title is ${video.title}`);\n     *    else console.log('video not found :(');\n     *  })\n     *  .catch(console.error);\n     */\n    getVideo(url, options = {}) {\n        const id = Video.extractID(url);\n        if (!id) return Promise.reject(new Error(`No video ID found in URL: ${url}`));\n        return this.getVideoByID(id, options);\n    }\n\n    /**\n     * Get a video by ID\n     * @param {string} id The video ID\n     * @param {Object} [options = {}] Options to request with the video.\n     * @returns {Promise<?Video>}\n     * @example\n     * API.getVideoByID('3odIdmuFfEY')\n     *  .then(video => {\n     *    if (video) console.log(`The video's title is ${video.title}`);\n     *    else console.log('video not found :(');\n     *  })\n     *  .catch(console.error);\n     */\n    getVideoByID(id, options = {}) {\n        return this.request.getVideo(id, options).then(result => result ? new Video(this, result) : null);\n    }\n\n    /**\n     * Get a playlist by URL or ID\n     * @param {string} url The playlist URL or ID\n     * @param {Object} [options = {}] Options to request with the playlist.\n     * @returns {Promise<?Playlist>}\n     * @example\n     * API.getPlaylist('https://www.youtube.com/playlist?list=PLuY9odN8x9puRuCxiddyRzJ3F5jR-Gun9')\n     *  .then(playlist => {\n     *    if (playlist) console.log(`The playlist's title is ${playlist.title}`);\n     *    else console.log('playlist not found :(');\n     *  })\n     *  .catch(console.error);\n     */\n    getPlaylist(url, options = {}) {\n        const id = Playlist.extractID(url);\n        if (!id) return Promise.reject(new Error(`No playlist ID found in URL: ${url}`));\n        return this.getPlaylistByID(id, options);\n    }\n\n    /**\n     * Get a playlist by ID\n     * @param {string} id The playlist ID\n     * @param {Object} [options = {}] Options to request with the playlist.\n     * @returns {Promise<?Playlist>}\n     * @example\n     * API.getPlaylistByID('PL2BN1Zd8U_MsyMeK8r9Vdv1lnQGtoJaSa')\n     *  .then(playlist => {\n     *    if (playlist) console.log(`The playlist's title is ${playlist.title}`);\n     *    else console.log('playlist not found :(');\n     *  })\n     *  .catch(console.error);\n     */\n    getPlaylistByID(id, options = {}) {\n        return this.request.getPlaylist(id, options).then(result => result ? new Playlist(this, result) : null);\n    }\n\n    /**\n     * Get a channel by URL or ID\n     * @param {string} url The channel URL or ID\n     * @param {Object} [options = {}] Options to request with the channel.\n     * @returns {Promise<?Channel>}\n     * @example\n     * API.getChannel('https://www.youtube.com/channel/UC477Kvszl9JivqOxN1dFgPQ')\n     *  .then(channel => {\n     *    if (channel) console.log(`The channel's title is ${channel.title}`);\n     *    else console.log('channel not found :(');\n     *  })\n     *  .catch(console.error);\n     */\n    getChannel(url, options = {}) {\n        const id = Channel.extractID(url);\n        if (!id) return Promise.reject(new Error(`No channel ID found in URL: ${url}`));\n        return this.getChannelByID(id, options);\n    }\n\n    /**\n     * Get a channel by ID\n     * @param {string} id The channel ID\n     * @param {Object} [options = {}] Options to request with the channel.\n     * @returns {Promise<?Channel>}\n     * @example\n     * API.getChannelByID('UC477Kvszl9JivqOxN1dFgPQ')\n     *  .then(channel => {\n     *    if (channel) console.log(`The channel's title is ${channel.title}`);\n     *    else console.log('channel not found :(');\n     *  })\n     *  .catch(console.error);\n     */\n    getChannelByID(id, options = {}) {\n        return this.request.getChannel(id, options).then(result => result ? new Channel(this, result) : null);\n    }\n\n    /**\n     * Search YouTube for videos, playlists, and channels\n     * @param {string} query The string to search for\n     * @param {number} [limit = 5] Maximum results to obtain\n     * @param {Object} [options] Additional options to pass to the API request\n     * @returns {Promise<Array<Video|Playlist|Channel|null>>}\n     * @example\n     * API.search('Centuries')\n     *  .then(results => {\n     *    console.log(`I got ${results.length} results`);\n     *  })\n     *  .catch(console.error);\n     */\n    search(query, limit = 5, options = {}) {\n        return this.request.getPaginated(Constants.ENDPOINTS.Search, limit, Object.assign(options, { q: query, part: Constants.PARTS.Search }))\n            .then(result => result.map(item => {\n                if (item.id.kind === Constants.KINDS.Video) return new Video(this, item);\n                if (item.id.kind === Constants.KINDS.Playlist) return new Playlist(this, item);\n                if (item.id.kind === Constants.KINDS.Channel) return new Channel(this, item);\n                return null;\n            }));\n    }\n\n    /**\n     * Search YouTube for videos\n     * @param {string} query The string to search for\n     * @param {number} [limit = 5] Maximum results to obtain\n     * @param {Object} [options] Additional options to pass to the API request\n     * @returns {Promise<Video[]>}\n     * @example\n     * API.searchVideos('Centuries')\n     *  .then(results => {\n     *    console.log(`I got ${results.length} videos`);\n     *  })\n     *  .catch(console.error);\n     */\n    searchVideos(query, limit = 5, options = {}) {\n        return this.search(query, limit, Object.assign(options, { type: 'video' }));\n    }\n\n    /**\n     * Search YouTube for playlists\n     * @param {string} query The string to search for\n     * @param {number} [limit = 5] Maximum results to obtain\n     * @param {Object} [options] Additional options to pass to the API request\n     * @returns {Promise<Playlist[]>}\n     * @example\n     * API.searchPlaylists('Centuries')\n     *  .then(results => {\n     *    console.log(`I got ${results.length} playlists`);\n     *  })\n     *  .catch(console.error);\n     */\n    searchPlaylists(query, limit = 5, options = {}) {\n        return this.search(query, limit, Object.assign(options, { type: 'playlist' }));\n    }\n\n    /**\n     * Search YouTube for channels\n     * @param {string} query The string to search for\n     * @param {number} [limit = 5] Maximum results to obtain\n     * @param {Object} [options] Additional options to pass to the API request\n     * @returns {Promise<Channel[]>}\n     * @example\n     * API.searchChannels('Centuries')\n     *  .then(results => {\n     *    console.log(`I got ${results.length} channels`);\n     *  })\n     *  .catch(console.error);\n     */\n    searchChannels(query, limit = 5, options = {}) {\n        return this.search(query, limit, Object.assign(options, { type: 'channel' }));\n    }\n}\n\nYouTube.Video = Video;\nYouTube.Playlist = Playlist;\nYouTube.Channel = Channel;\nYouTube.util = util;\n\nmodule.exports = YouTube;\n"]}