From c522516b8867fbc7ab291ac7064cd369af14e958 Mon Sep 17 00:00:00 2001 From: Calvin Montgomery Date: Thu, 10 Jul 2014 23:03:13 -0700 Subject: [PATCH] Implement serverside Google+ retrieval --- gptest.js | 2 +- lib/get-info.js | 75 +++++++++++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 31 deletions(-) diff --git a/gptest.js b/gptest.js index e8f6cd0c..852fad98 100644 --- a/gptest.js +++ b/gptest.js @@ -2,7 +2,7 @@ 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"); +var id = link.replace(/https:\/\/plus\.google\.com\/photos\/(\d+)\/albums\/(\d+)\/(\d+)/, "$1_$2_$3"); gp(id, function (err, data) { if (err) console.error(err) diff --git a/lib/get-info.js b/lib/get-info.js index 18af7693..c204cfae 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -787,16 +787,21 @@ var Getters = { }); }, - /* google+ photo videos */ + /* + * Google+ videos + * + * This is quite possibly the hackiest video metadata retrieval function + * in CyTube. + */ gp: function (id, cb) { - id = id.split("_"); - if (id.length !== 2) { + var idparts = id.split("_"); + if (idparts.length !== 3) { return cb("Invalid Google+ video ID"); } var options = { host: "plus.google.com", - path: "/photos/" + id[0] + "/albums/" + id[1], + path: "/photos/" + idparts[0] + "/albums/" + idparts[1] + "/" + idparts[2], port: 443 }; @@ -817,27 +822,38 @@ var Getters = { return callback("HTTP " + status, null); } - res = res.replace(/\s/g, ""); - var results = res.match(/