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AO,KAAK,EAAO,EAAI,GACzB,IAEN,EAAI,KAAK,IAGT,EAAI,KAAK,KAAK,EAEtB,IACA,QAAQ,iBAAmB,CAAC,EAAM,KAC9B,MAAM,EAAS,aAAa,GAC5B,IAAK,EAAK,KACN,MAAM,IAAI,MAAM,yFAIpB,OADA,yBAAyB,EAAQ,EAAM,GAChC,CAAM,EAEjB,QAAQ,QAAU,KAClB,QAAQ,aAAe,KAAK,aAC5B,QAAQ,QAAU,KAAK,YACvB,QAAQ,aAAe,KAAK,aAC5B,QAAQ,cAAgB,KAAK,cAC7B,QAAQ,WAAa,KAAK,WAC1B,QAAQ,YAAc,KAAK,YAC3B,QAAQ,cAAgB,KAAK,cAC7B,QAAQ,WAAa,KAAK,WAC1B,QAAQ,MAAQ,OAAO,OAAO,CAC1B,IAAK,IAAI,MACT,KAAM,KAAK","file":"/npm/ytdl-core-new@1.1.2/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ytdl-core-new@1.1.2/dist/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","\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importStar = (this && this.__importStar) || function (mod) {\n    if (mod && mod.__esModule) return mod;\n    var result = {};\n    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\n    result[\"default\"] = mod;\n    return result;\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst stream_1 = require(\"stream\");\nconst info = __importStar(require(\"./info\"));\nconst util = __importStar(require(\"./util\"));\nconst sig = __importStar(require(\"./sig\"));\nconst axios_1 = __importDefault(require(\"axios\"));\nconst m3u8stream_1 = __importDefault(require(\"m3u8stream\"));\nconst parse_time_1 = __importDefault(require(\"m3u8stream/dist/parse-time\"));\nconst client_1 = __importDefault(require(\"./client\"));\nconst ytdl = (link, options) => {\n    const stream = createStream(options);\n    exports.getInfo(link, options)\n        .then((info) => {\n        stream.emit('info', info);\n        return downloadFromInfoCallback(stream, info, options);\n    })\n        .catch((e) => stream.emit('error', e));\n    return stream;\n};\nexports.ytdl = ytdl;\nconst createStream = (options) => {\n    var _a, _b;\n    const stream = new stream_1.PassThrough({\n        highWaterMark: (_b = (_a = options) === null || _a === void 0 ? void 0 : _a.highWaterMark, (_b !== null && _b !== void 0 ? _b : null)),\n    });\n    stream.destroy = () => {\n        stream._isDestroyed = true;\n    };\n    return stream;\n};\n/**\n * Chooses a format to download.\n *\n * @param {stream.Readable} stream\n * @param {Object} info\n * @param {Object} options\n */\nconst downloadFromInfoCallback = (stream, info, options) => __awaiter(void 0, void 0, void 0, function* () {\n    options = options || {};\n    const format = util.chooseFormat(info.formats, options);\n    if (format instanceof Error) {\n        // The caller expects this function to be async.\n        setImmediate(() => {\n            stream.emit('error', format);\n        });\n        return;\n    }\n    stream.emit('info', { info, format });\n    if (stream._isDestroyed) {\n        return;\n    }\n    let contentLength = 0;\n    let downloaded = 0;\n    const ondata = (chunk) => {\n        downloaded += chunk.length;\n        stream.emit('progress', {\n            chunkLength: chunk.length,\n            downloaded,\n            total: contentLength,\n        });\n    };\n    let reqType;\n    let req;\n    if (format.isHLS || format.isDashMPD) {\n        reqType = 'miniget';\n        req = m3u8stream_1.default(format.url, {\n            chunkReadahead: +info.live_chunk_readahead,\n            begin: (options.begin || format.live && Date.now()),\n            liveBuffer: options.liveBuffer,\n            requestOptions: (options.requestOptions),\n            parser: format.isDashMPD ? 'dash-mpd' : 'm3u8',\n            id: format.itag,\n        });\n        req.on('progress', (segment, totalSegments) => {\n            stream.emit('progress', {\n                chunkLength: segment.size,\n                downloaded: segment.num,\n                total: totalSegments,\n            });\n        });\n    }\n    else {\n        if (options.begin) {\n            format.url += '&begin=' + parse_time_1.default.humanStr(options.begin);\n        }\n        let requestOptions = Object.assign({}, options.requestOptions);\n        if (options.range && (options.range.start || options.range.end)) {\n            requestOptions.headers = Object.assign({}, requestOptions.headers, {\n                Range: `bytes=${options.range.start || '0'}-${options.range.end || ''}`,\n            });\n        }\n        reqType = 'axios';\n        const source = axios_1.default.CancelToken.source();\n        req = yield client_1.default.get(format.url, Object.assign(Object.assign({}, requestOptions), { headers: Object.assign({ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36', Referer: `https://www.youtube.com/watch/${info.video_id}` }, requestOptions.headers), responseType: 'stream', cancelToken: source.token }));\n        stream.emit('response', req);\n        req.abort = () => source.cancel();\n        if (stream._isDestroyed) {\n            return;\n        }\n        if (!contentLength) {\n            contentLength = Number(req.headers['content-length']);\n        }\n        req.data.on('data', ondata);\n    }\n    stream.destroy = () => {\n        var _a, _b, _c, _d, _e, _f, _g, _h;\n        stream._isDestroyed = true;\n        if (req.abort)\n            req.abort();\n        (_b = (_a = req).end) === null || _b === void 0 ? void 0 : _b.call(_a);\n        (_d = (_c = req).removeListener) === null || _d === void 0 ? void 0 : _d.call(_c, 'data', ondata);\n        if (reqType === 'miniget') {\n            (_f = (_e = req).unpipe) === null || _f === void 0 ? void 0 : _f.call(_e);\n        }\n        else {\n            (_h = (_g = req.data).unpipe) === null || _h === void 0 ? void 0 : _h.call(_g);\n        }\n    };\n    if (reqType === 'miniget') {\n        // Forward events from the request to the stream.\n        [\n            'abort', 'request', 'response', 'error', 'retry', 'reconnect',\n        ].forEach((event) => {\n            var _a, _b;\n            (_b = (_a = req).prependListener) === null || _b === void 0 ? void 0 : _b.call(_a, event, (arg) => {\n                stream.emit(event, arg);\n            });\n        });\n        req.pipe(stream);\n    }\n    else {\n        req.data.pipe(stream);\n    }\n});\nexports.downloadFromInfo = (info, options) => {\n    const stream = createStream(options);\n    if (!info.full) {\n        throw new Error('Cannot use `ytdl.downloadFromInfo()` when called ' +\n            'with info from `ytdl.getBasicInfo()`');\n    }\n    downloadFromInfoCallback(stream, info, options);\n    return stream;\n};\nexports.default = ytdl;\nexports.getBasicInfo = info.getBasicInfo;\nexports.getInfo = info.getFullInfo;\nexports.chooseFormat = util.chooseFormat;\nexports.filterFormats = util.filterFormats;\nexports.validateID = util.validateID;\nexports.validateURL = util.validateURL;\nexports.getURLVideoID = util.getURLVideoID;\nexports.getVideoID = util.getVideoID;\nexports.cache = Object.freeze({\n    sig: sig.cache,\n    info: info.cache,\n});\n"]}