-
-
Save rachhen/ddb09457d99bfbc52097b859fbcc1ec5 to your computer and use it in GitHub Desktop.
Revisions
-
max-te revised this gist
Sep 17, 2012 . 1 changed file with 29 additions and 29 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,47 +11,47 @@ http.get("http://www.youtube.com/get_video_info?video_id="+videoID, function(res res.on('data', function(chunk){chunks.push(chunk) }).on('end', function(){ var data = Buffer.concat(chunks).toString() var videoInfo = parseVideoInfo(data) downloadVideo(videoInfo) }) }).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]) var rxUrlG = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/g var rxUrl = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ var urls = urlmap.match(rxUrlG) urls = map(urls, function(s) {return s.match(rxUrl)[1]} ) urls = map(urls, unescape) var rxTitle = /title=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ var title = argv.o ? argv.o : videoInfo.match(rxTitle)[1] return { title: title, urls: urls } } function downloadVideo(videoInfo) { var url = videoInfo.urls[0]; var filename = videoInfo.title + ".flv" http.get(url, function(res) { var stream = fs.createWriteStream(filename) res.pipe(stream) }) console.log("Downloading to "+filename); } function map (a,f) { for(i=0;i<a.length;i++){ a[i]= f(a[i]) } return a } -
max-te revised this gist
Sep 17, 2012 . 1 changed file with 11 additions and 7 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,12 @@ var http = require('http') var fs = require('fs') var argv = require('optimist').argv var rxVideoID = /v=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ var link = argv._.toString() var videoID = link.match(rxVideoID)[1] http.get("http://www.youtube.com/get_video_info?video_id="+videoID, function(res) { var chunks = [] res.on('data', function(chunk){chunks.push(chunk) }).on('end', function(){ @@ -22,29 +21,34 @@ http.get("http://www.youtube.com/get_video_info?video_id="+videoID, function(res function parseVideoInfo(videoInfo) { var rxUrlMap = /url_encoded_fmt_stream_map=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ urlmap = unescape(videoInfo.match(rxUrlMap)[1]) var rxUrlG = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/g var rxUrl = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ var urls = urlmap.match(rxUrlG) urls = map(urls, function(s) {return s.match(rxUrl)[1]} ) urls = map(urls, unescape) var rxTitle = /title=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ var title = argv.o ? argv.o : videoInfo.match(rxTitle)[1] return { title: title, urls: urls } } function downloadVideo(videoInfo) { var url = videoInfo.urls[0]; var filename = videoInfo.title + ".flv" http.get(url, function(res) { var stream = fs.createWriteStream(filename) res.pipe(stream) }) console.log("Downloading to "+filename); } function map (a,f) { for(i=0;i<a.length;i++){ a[i]= f(a[i]) -
max-te revised this gist
Sep 17, 2012 . 1 changed file with 11 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,12 @@ var http = require('http') var fs = require('fs') var videoID = "C0DPdy98e4c" var input = process.argv[2] var rxVideoID = /v=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ videoID = input.match(rxVideoID, input)[1] http.get("http://www.youtube.com/get_video_info?video_id="+videoID, function(res) { //console.log("Got response: " + res.statusCode); var chunks = [] res.on('data', function(chunk){chunks.push(chunk) @@ -20,11 +25,13 @@ function parseVideoInfo(videoInfo) { //console.log(urlmap); var rxUrlG = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/g var rxUrl = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ var urls = urlmap.match(rxUrlG) urls = map(urls, function(s) {return s.match(rxUrl)[1]} ) urls = map(urls, unescape) var rxTitle = /title=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ var title = videoInfo.match(rxTitle)[1] //console.log(urls[0]) return { title: title, urls: urls } } function downloadVideo(videoInfo) { @@ -35,7 +42,7 @@ function downloadVideo(videoInfo) { var stream = fs.createWriteStream(filename) res.pipe(stream) }) console.log("Downloading to "+filename); } function map (a,f) { -
max-te revised this gist
Sep 17, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,7 @@ function downloadVideo(videoInfo) { var stream = fs.createWriteStream(filename) res.pipe(stream) }) console.log("Downloading to "+filename) } function map (a,f) { -
max-te revised this gist
Sep 17, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -35,7 +35,7 @@ function downloadVideo(videoInfo) { var stream = fs.createWriteStream(filename) res.pipe(stream) }) console.log("Downloading to "+filename); } function map (a,f) { -
max-te revised this gist
Sep 17, 2012 . 1 changed file with 38 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,46 @@ var http = require('http') var fs = require('fs') 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) }).on('end', function(){ var data = Buffer.concat(chunks).toString() var videoInfo = parseVideoInfo(data) downloadVideo(videoInfo) }) }).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 rxUrlG = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/g var rxUrl = /url=([\]\[!"#$%'()*+,.\/:;<=>?@\^_`{|}~-\w]*)/ urls = urlmap.match(rxUrlG) urls = map(urls, function(s) {return s.match(rxUrl)[1]} ) urls = map(urls, unescape) //console.log(urls[0]) return { title:"test", urls: urls } } function downloadVideo(videoInfo) { var url = videoInfo.urls[0]; var filename = videoInfo.title + ".flv" http.get(url, function(res) { var stream = fs.createWriteStream(filename) res.pipe(stream) }) console.log("Downloading to "+filename"); } function map (a,f) { for(i=0;i<a.length;i++){ a[i]= f(a[i]) } return a } -
max-te created this gist
Sep 17, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ 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); }