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('http://www.youtube.com/watch?v=A02s8omM_hI')
.pipe(fs.createWriteStream('video.flv'));
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
, orlowest
. Defaults tohighest
.start
- Where to begin downloading the video in milliseconds or in a time format ie1m34s
.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.
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.
Use this if you only want to get metainfo from a video. info
may look like this.
npm install ytdl
ytdl can be used from the command line too. Install with the -g
flag to use it.
ytdl http://www.youtube.com/watch?v=_HSylqgVYQI > cat.flv
And it streams!
Usage: ytdl <url> [options]
url URL to the video.
Options:
-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
MIT