youtube-dl-exec 问题 - 获取可读流

问题描述 投票:0回答:1

我正在尝试从 youtube-dl-exec 获取可读流。

youtubedl(url, {
    dumpSingleJson: true,
    noWarnings: true,
    audioFormat: 'mp3',
    //audioQuality: 0,
    noCheckCertificate: true,
    preferFreeFormats: true,
    youtubeSkipDashManifest: true,
    referer: 'https://google.com'
})
.then(async output => {
    let resource = createAudioResource(output); // output = YtResponse (JSON)
})
.catch(err => console.error(err));

输出是 YtResponse 类型(带有格式和 URL、缩略图等的 JSON)

所以

let url = output.formats[0]?.url;

我可以获得一个类似的 URL

https://r1---sn-h0jelnez.googlevideo.com/videoplayback?expire=

但是我无法流式传输它,因为它不是可读流..

所以我尝试使用

youtube-dl
库。但如果我不想安装它,我会收到此错误:

npm ERR! command C:\Windows\system32\cmd.exe /d /s /c npm run check && npm run download
npm ERR! > [email protected] check
npm ERR! > bin-version-check python '>=2'
npm ERR! Error: Invalid version range
npm ERR!     at module.exports (C:\Users\Admin\Documents\Nodejs\LL-Bot-Musik\node_modules\bin-version-check\index.js:12:25)
npm ERR!     at Object.<anonymous> (C:\Users\Admin\Documents\Nodejs\LL-Bot-Musik\node_modules\bin-version-check-cli\cli.js:29:1)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1101:14)
npm ERR!     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:981:32)
npm ERR!     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
npm ERR!     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
npm ERR!     at node:internal/main/run_main_module:17:47

npm ERR! A complete log of this run can be found in:

现在我不知道我能做什么..

node.js npm discord.js youtube-dl
1个回答
0
投票

如果你想让它不向你发送 JSON,你所要做的就是删除

dumpSingleJson: true
或使其成为
false

© www.soinside.com 2019 - 2024. All rights reserved.