diff --git a/gdocstest.js b/gdocstest.js new file mode 100644 index 00000000..ca918209 --- /dev/null +++ b/gdocstest.js @@ -0,0 +1,8 @@ +var gi = require('./lib/get-info'); +var gd = gi.Getters.gd; + +gd(process.argv[2], function (err, data) { + if (err) console.error(err) + else console.log(data.meta.params.map(function (p) { return decodeURIComponent(p.value); })); + process.exit(0); +}); diff --git a/gptest.js b/gptest.js new file mode 100644 index 00000000..e8f6cd0c --- /dev/null +++ b/gptest.js @@ -0,0 +1,11 @@ +var gi = require('./lib/get-info'); +var gp = gi.Getters.gp; + +var link = process.argv[2]; +var id = link.replace(/https:\/\/plus\.google\.com\/photos\/(\d+)\/albums\/(\d+)/, "$1_$2"); + +gp(id, function (err, data) { + if (err) console.error(err) + else console.log(data); + process.exit(0); +}); diff --git a/lib/get-info.js b/lib/get-info.js index 6db122c0..18af7693 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -715,6 +715,11 @@ var Getters = { }); data = "[" + data + "]"; var js = JSON.parse(data); + + if (js[1].videoplay.status === "QUOTA_DENIED") { + return callback("Google Docs error: Video has exceeded quota", null); + } + var title = js[0].title; var seconds = js[1].videodetails.duration / 1000; var meta = {}; @@ -780,6 +785,101 @@ var Getters = { }); cb(null, m); }); + }, + + /* google+ photo videos */ + gp: function (id, cb) { + id = id.split("_"); + if (id.length !== 2) { + return cb("Invalid Google+ video ID"); + } + + var options = { + host: "plus.google.com", + path: "/photos/" + id[0] + "/albums/" + id[1], + port: 443 + }; + + urlRetrieve(https, options, function (status, res) { + switch (status) { + case 200: + break; /* Request is OK, skip to handling data */ + case 400: + return callback("Invalid request", null); + case 403: + return callback("Private video", null); + case 404: + return callback("Video not found", null); + case 500: + case 503: + return callback("Service unavailable", null); + default: + return callback("HTTP " + status, null); + } + + res = res.replace(/\s/g, ""); + var results = res.match(/