Nodejs Youtube:生成未知错误
Nodejs Youtube : Spawn unknown error
我在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 上遇到了同样的问题,我将其修复为:
第一步:
转到此 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
*/
对于完整的文件和 运行ning 项目:
克隆 node-cheat youtube_download_videos、运行 node download_script.js
然后是 npm i youtube-dl
.
我在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 上遇到了同样的问题,我将其修复为:
第一步: 转到此 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
*/
对于完整的文件和 运行ning 项目:
克隆 node-cheat youtube_download_videos、运行 node download_script.js
然后是 npm i youtube-dl
.