【问题标题】:Nodejs Youtube : Spawn unknown errorNodejs Youtube:产生未知错误
【发布时间】:2018-09-21 01:13:27
【问题描述】:

我在 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'));

我得到这个错误:-

生成未知

您还可以提出另一种制作 youtube 下载器的方法。

【问题讨论】:

  • this link 可以帮到你
  • @9275462 看看我的回答是否适合你。
  • 替换它们需要无限时间

标签: node.js download youtube-api youtube-data-api youtube-dl


【解决方案1】:

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

第 1 步: 转到这个linkhttps://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
*/

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

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

【讨论】:

    猜你喜欢
    • 2015-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-29
    • 2016-12-10
    相关资源
    最近更新 更多