Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Davide Pastore DavidePastore
file 116 lines (82 sloc) 4.196 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('itag:', info.itag);
  console.log('resolution:', info.resolution);

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
itag: 34
resolution: 360x640

Getting available formats

var youtubedl = require('youtube-dl');
var url = '';
youtubedl.getFormats(url, function(err, formats) {
  if (err) throw err;

  formats.forEach(function(format) {

Will print something like

{ itag: 34, filetype: 'flv', resolution: '360x640' }
{ itag: 18, filetype: 'mp4', resolution: '360x640' }
{ itag: 43, filetype: 'webm', resolution: '360x640' }
{ itag: 5, filetype: 'flv', resolution: '240x400' }
{ itag: 17, filetype: 'mp4', resolution: '144x176' }

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.


npm install youtube-dl


Tests are written with vows

npm test



Something went wrong with that request. Please try again.