【发布时间】:2021-09-07 01:39:28
【问题描述】:
当我尝试在 ytdl-core 中从 YouTube 提取音乐时,我在控制台上收到 404 错误。此错误来自 miniget 包。 ytdl-core 正在使用 miniget。
代码:
ytdl("https://www.youtube.com/watch?v=" + stream.id);
控制台:
(node:16438) UnhandledPromiseRejectionWarning: Error: Status code: 404
at ClientRequest.<anonymous> (/rbd/pnpm-volume/59a3a74b-3917-4637-83d3-08984c5b8ec9/node_modules/.registry.npmjs.org/miniget/4.2.1/node_modules/miniget/dist/index.js:210:27)
at Object.onceWrapper (events.js:284:20)
at ClientRequest.emit (events.js:196:13)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:23)
at HTTPParser.parserOnHeadersComplete (_http_common.js:116:17)
at TLSSocket.socketOnData (_http_client.js:452:22)
at TLSSocket.emit (events.js:196:13)
at addChunk (_stream_readable.js:290:12)
at readableAddChunk (_stream_readable.js:271:11)
at TLSSocket.Readable.push (_stream_readable.js:226:10)
(node:16438) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
如何解决?
【问题讨论】:
-
据我所知,404是用来表示“Not Found”错误的,可能是
stream.id添加到"https://www.youtube.com/watch?v="后形成的URL不会导致一个有效的youtube视频。跨度>
标签: node.js discord discord.js ytdl