-
-
Save rachhen/ddb09457d99bfbc52097b859fbcc1ec5 to your computer and use it in GitHub Desktop.
Download Youtube-Video in node.js
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
| var http = require('http'); | |
| http.get("http://www.youtube.com/get_video_info?video_id=F_CvDj8pLo0", function(res) { | |
| console.log("Got response: " + res.statusCode); | |
| var chunks = []; | |
| res.on('data', function(chunk){chunks.push(chunk)} ); | |
| res.on('end', function(){ parseVideoInfo(Buffer.concat(chunks).toString()) } ) | |
| }).on('error', function(e) { | |
| console.log("Got error: " + e.message); | |
| }); | |
| function parseVideoInfo(videoInfo) { | |
| var rxUrlMap = /url_encoded_fmt_stream_map=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/; | |
| urlmap = unescape(videoInfo.match(rxUrlMap)[1]); | |
| //console.log(urlmap); | |
| var rxUrl= /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/; | |
| url = unescape(urlmap.match(rxUrl)[1]) | |
| console.log(url); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment