From ad1389673939b9519f6157a2f725ab485958f5b8 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Fri, 20 Feb 2015 22:59:11 -0600 Subject: [PATCH 1/2] Make gdocs retrieval less janky --- lib/get-info.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/get-info.js b/lib/get-info.js index c07d0b09..9979f91c 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -688,7 +688,7 @@ var Getters = { /* WARNING: hacks inbound */ var options = { host: "docs.google.com", - path: "/file/d/" + id + "/view?sle=true", + path: "/file/d/" + id + "/get_video_info?sle=true", port: 443 }; @@ -709,16 +709,11 @@ var Getters = { return callback("HTTP " + status, null); } - /* - * Match [[anything]] and ignore whitespace - * Fix 2014-08-07: [^] matches \r\n, . doesn't. - */ - var m = res.match(/\[(\[\s*\[[^\[][^]*?\]\s*\])/); try { - var propertyList = JSON.parse(m[1]); var data = {}; - propertyList.forEach(function (kv) { - data[kv[0]] = kv[1]; + res.split("&").forEach(function (urlparam) { + var pair = urlparam.split("=").map(decodeURIComponent); + data[pair[0]] = pair[1]; }); if (data.hasOwnProperty("reason")) { From c9025fbb4426f78f5b12a7464bdddc8267084dd6 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Fri, 20 Feb 2015 23:11:09 -0600 Subject: [PATCH 2/2] Fix titles and error messages --- lib/get-info.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/get-info.js b/lib/get-info.js index 9979f91c..9a53f359 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -710,9 +710,11 @@ var Getters = { } try { + var data = {}; res.split("&").forEach(function (urlparam) { - var pair = urlparam.split("=").map(decodeURIComponent); + var pair = urlparam.split("=").map(decodeURIComponent).map( + function (s) { return s.replace(/\+/g, ' '); }); data[pair[0]] = pair[1]; }); @@ -721,8 +723,12 @@ var Getters = { if (reason.indexOf("Unable to play this video at this time.") === 0) { reason = "There is currently a bug with Google Drive which prevents playback " + "of videos 1 hour long or longer."; + } else if (reason.indexOf( + "You must be signed in to access this video") >= 0) { + reason = "This video is not shared properly"; } + return callback(reason); }