Created
October 2, 2012 16:49
-
-
Save bmpvieira/3821033 to your computer and use it in GitHub Desktop.
Simple Youtube playlist parser using JSONStream
This file contains hidden or 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
/* | |
author: bmpvieira | |
license: WTFPL | |
description: Simple Youtube playlist parser using https://github.com/dominictarr/JSONStream | |
usage example: node youtubePlaylistParser.js PLt4dwg5cC5TSqHR44YK0UQ_8TSG8YtZtI | cclive -f best -c | |
*/ | |
var request = require('request'); | |
var JSONStream = require('JSONStream'); | |
var playlistID = process.argv[2]; | |
var url = "https://gdata.youtube.com/feeds/api/playlists/" + playlistID + "?v=2&alt=jsonc" | |
var parser = JSONStream.parse(['data', 'items', true, 'video', 'id']); | |
parser.on("data", function(data) { | |
console.log("http://www.youtube.com/watch?v=" + data); | |
}); | |
parser.on("root", function(root, count) { | |
if (!count) { | |
console.log('no matches found:', root); | |
} | |
}); | |
request(url).pipe(parser); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment