Merge pull request #454 from calzoneman/gdocs-refactor

Gdocs refactor
This commit is contained in:
Calvin Montgomery 2015-02-24 10:42:35 -06:00
commit 6ab609db71
1 changed files with 10 additions and 9 deletions

View File

@ -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,13 @@ 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).map(
function (s) { return s.replace(/\+/g, ' '); });
data[pair[0]] = pair[1];
});
if (data.hasOwnProperty("reason")) {
@ -726,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);
}