gpt4 book ai didi

node.js - Nodejs YouTube : Spawn unknown error

转载 作者:太空宇宙 更新时间:2023-11-03 23:00:23 25 4
gpt4 key购买 nike

我在nodejs中的代码是这样的:-

var fs = require('fs');
var youtubedl = require('youtube-dl');
var video = youtubedl('http://www.youtube.com/watch?v=90AiXO1pAiA',
// Optional arguments passed to youtube-dl.

// Additional options can be given for calling `child_process.execFile()`.
);

// Will be called when the download starts.

video.on('info', function(info) {
console.log('Download started');
console.log('filename: ' + info.filename);
console.log('size: ' + info.size);
});

video.pipe(fs.createWriteStream('myvideo.mp4'));

我收到此错误:-

SPAWN unknown

您还可以建议另一种制作 YouTube 下载器的方法。

最佳答案

我在 Windows 上遇到同样的问题,我将其修复为:

第 1 步:转到此link : https://rg3.github.io/youtube-dl/download.html

第 2 步:下载Windows exe (sig - SHA256 7071c7a2.....................)

第 3 步:将其替换为 \node_modules\youtube-dl\bin

第 4 步:运行您的代码:

const fs = require('fs');
const youTube = require('youtube-dl');
const video = youTube('http://www.youtube.com/watch?v=90AiXO1pAiA');

// called when the download starts.
video.on('info', function(info) {
console.log('Download started');
console.log('filename: ' + info.filename);
console.log('size: ' + info.size);
});

video.pipe(fs.createWriteStream('downloads/downloaded_video.mp4'));

第 5 步:预期控制台输出:

/*  Sample Output   */
/*
Download started
filename: lol-90AiXO1pAiA.webm
size: 1029843
NOTE: File will be downloaded in downloads folder
*/

完整文件和正在运行的项目:

克隆 Node 作弊 youtube_download_videos ,运行 node download_script.js,然后运行 ​​npm i youtube-dl

关于node.js - Nodejs YouTube : Spawn unknown error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49770196/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com