Last active
December 27, 2015 22:09
-
-
Save jfretin/7397485 to your computer and use it in GitHub Desktop.
Dowload Youtube playlist videos, with node.js.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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