Skip to content

Instantly share code, notes, and snippets.

@jfretin
Last active December 27, 2015 22:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jfretin/7397485 to your computer and use it in GitHub Desktop.
Dowload Youtube playlist videos, with node.js.
var youtube = require('youtube-feeds');
var fs = require('fs');
var ytdl = require('ytdl');
var slug = require('slug-component');
youtube.httpProtocol = 'http';
var videos = null;
youtube.feeds.playlist("PL8Mfzkj8FPJtepq2syn8nFKtOWdyPigE_",{} ,
function( err, data ) {
if( err instanceof Error ) {
console.log( err )
} else {
var vid = "", url = "";
for (v in data.items) {
vid = data.items[v].video.id;
title = slug(data.items[v].video.title);
console.log(title);
url = "http://www.youtube.com/watch?v=" + vid;
ytdl(url, { filter: function(format) { return format.container === 'mp4'; } })
.pipe(fs.createWriteStream(title + ".mp4"));
}
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment