Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

151 lines (110 sloc) 5.09 kb

youtube-dl Build Status

Download videos from youtube in node.js using youtube-dl.

I also made a pure Javascript youtube downloading module. The reason I'm maintaining this one is because it supports a lot more video sites besides youtube.

If you're only interested in downloading only from youtube, you should consider using the other module.


Downloading videos

var fs = require('fs');
var youtubedl = require('youtube-dl');
var video = youtubedl('',
  // Optional arguments passed to youtube-dl.
  // Additional options can be given for calling `child_process.execFile()`.
  { cwd: __dirname });

// 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);


A similar example can be found in the example folder, and will produce an output that looks like the following when ran.

Got video info
saving to T-ara - Number Nine - MV - 티아라-Seku9G1kT0c.mp4

Getting video information

var youtubedl = require('youtube-dl');
var url = '';
// Optional arguments passed to youtube-dl.
var options = ['--username=user', '--password=hunter2'];
youtubedl.getInfo(url, options, function(err, info) {
  if (err) throw err;

  console.log('title:', info.title);
  console.log('url:', info.url);
  console.log('thumbnail:', info.thumbnail);
  console.log('description:', info.description);
  console.log('filename:', info._filename);
  console.log('format id:', info.format_id);

Running that will produce something like

id: WKsjaOqDXgg
title: Ace Rimmer to the Rescue
description: An old Red Dwarf eposide where Ace Rimmer saves the Princess Bonjella.
filename: Ace Rimmer to the Rescue-WKsjaOqDXgg.flv
format id: 34

You can use an array of urls to produce an array of response objects with matching array index (e.g. the 1st response object will match the first url etc...)

var youtubedl = require('youtube-dl');
var url1 = '';
var url2 = '';
youtubedl.getInfo([url1, url2], function(err, info) {
  if (err) throw err;

  console.log('title for the url1:', info[0].title);
  console.log('title for the url2:', info[1].title);

Downloading subtitles

var youtubedl = require('youtube-dl');
var url = '';

var options = {
  // Write automatic subtitle file (youtube only)
  auto: false,
  // Downloads all the available subtitles.
  all: false,
  // Languages of subtitles to download, separated by commas.
  lang: 'en',
  // The directory to save the downloaded files in.
  cwd: __dirname,
youtubedl.getSubs(url, options, function(err, files) {
  if (err) throw err;

  console.log('subtitle files downloaded:', files);

For more usage info on youtube-dl and the arguments you can pass to it, do youtube-dl -h or go to the youtube-dl documentation.

Getting the list of extractors

var youtubedl = require('youtube-dl');
youtubedl.getExtractors(true, function(err, list) {
  console.log('Found ' + list.length + ' extractors');
  for (var i = 0; i < list.length; i++) {

Will print something like

Found 521 extractors


npm install youtube-dl

Since the youtube-dl binary is updated regularly, you can run npm update to check for and download any updates for it.


Tests are written with vows

npm test



Jump to Line
Something went wrong with that request. Please try again.