Fetching contributors…
Cannot retrieve contributors at this time
79 lines (49 sloc) 2.58 KB

node-ytdl Build Status

Yet another youtube downloading module. This time written with only Javascript and a more node-friendly streaming interface.


var fs = require('fs');
var ytdl = require('ytdl');



ytdl(url, options)

Attempts to download a video from the given url. Returns a readable stream. options can have the following keys

  • quality - Video quality to download. Can be an itag value value, highest, or lowest. Defaults to highest.
  • start - Where to begin downloading the video in milliseconds or in a time format ie 1m34s.
  • filter - You can give a filtering function that gets called with each format available. Used to decide what format to download.

options can also have any request options.

The returned readable stream emits these additional events.

Event: 'info'

  • Object - Info.
  • Object - Format.

Emitted when the a video's info hash is fetched. Along with the chosen format metadata to download. format.url might be different if start was given. format.size will also be available.

ytdl.getInfo(url, callback(err, info))

Use this if you only want to get metainfo from a video. info may look like this.


npm install yt


ytdl can be used from the command line too. Install with the -g flag to use it.

ytdl > cat.flv

And it streams!

Usage: ytdl <url> [options]

url     URL to the video.

   -v, --version                  Print program version.
   -q ITAG, --quality ITAG        Video quality to download. Default: `highest`
   -s TIME, --start TIME          Where to begin the video. ie 1m3s, 45s, 2300.
   -o FILE, --output FILE         Where to save the file. Default: stdout
   --filter-container REGEXP      Filter in format container.
   --unfilter-container REGEXP    Filter out format container.
   --filter-resolution REGEXP     Filter in format resolution.
   --unfilter-resolution REGEXP   Filter out format resolution.
   --filter-encoding REGEXP       Filter in format encoding.
   --unfilter-encoding REGEXP     Filter out format encoding.


Tests are written with mocha

npm test