A few minor fixes to the vimeo workaround
This commit is contained in:
parent
73235e5fbb
commit
00dd092fef
114
lib/get-info.js
114
lib/get-info.js
|
@ -702,51 +702,87 @@ var Getters = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A function name like this deserves an explanation.
|
||||||
|
*
|
||||||
|
* Vimeo blocked my domain from using their embed API, citing "volume of abuse" as the
|
||||||
|
* reason. After attempts to reach a compromise, Vimeo refused to unblock my domain.
|
||||||
|
*
|
||||||
|
* This function downloads the HTML for the embedded player and extracts direct links
|
||||||
|
* to the h264 encoded MP4 video files (with a session hash required for downloading it).
|
||||||
|
*
|
||||||
|
* This rivals the Google Drive playback functionality as quite possibly the hackiest code
|
||||||
|
* in CyTube. Thanks Vimeo, and may you never see a dime in advertising revenue from a
|
||||||
|
* CyTube client again.
|
||||||
|
*/
|
||||||
function VimeoIsADoucheCopter(id, cb) {
|
function VimeoIsADoucheCopter(id, cb) {
|
||||||
var options = {
|
var failcount = 0;
|
||||||
host: "player.vimeo.com",
|
|
||||||
path: "/video/" + id
|
|
||||||
};
|
|
||||||
|
|
||||||
var parse = function (data) {
|
var inner = function () {
|
||||||
var i = data.indexOf("a={");
|
var options = {
|
||||||
var j = data.indexOf("};", i);
|
host: "player.vimeo.com",
|
||||||
var json = data.substring(i+2, j+1);
|
path: "/video/" + id,
|
||||||
try {
|
headers: {
|
||||||
json = JSON.parse(json);
|
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0",
|
||||||
var codec = json.request.files.codecs[0];
|
"Referrer": "player.vimeo.com"
|
||||||
var files = json.request.files[codec];
|
|
||||||
setImmediate(function () {
|
|
||||||
cb(files);
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
if (data.indexOf("crawler") !== -1) {
|
|
||||||
setImmediate(function () {
|
|
||||||
VimeoIsADoucheCopter(id, cb);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Logger.errlog.log("Vimeo workaround error: ");
|
};
|
||||||
Logger.errlog.log(e);
|
|
||||||
Logger.errlog.log(data);
|
var parse = function (data) {
|
||||||
setImmediate(function () {
|
var i = data.indexOf("a={");
|
||||||
cb({});
|
var j = data.indexOf("};", i);
|
||||||
|
var json = data.substring(i+2, j+1);
|
||||||
|
try {
|
||||||
|
json = JSON.parse(json);
|
||||||
|
var codec = json.request.files.codecs[0];
|
||||||
|
var files = json.request.files[codec];
|
||||||
|
setImmediate(function () {
|
||||||
|
cb(files);
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// Not sure why the response sometimes differs. Trying to weed out
|
||||||
|
// search engines perhaps?
|
||||||
|
// Maybe adding the User-Agent above will fix this, I dunno
|
||||||
|
if (data.indexOf("crawler") !== -1) {
|
||||||
|
Logger.syslog.log("Warning: VimeoIsADoucheCopter got crawler response");
|
||||||
|
failcount++;
|
||||||
|
if (failcount > 4) {
|
||||||
|
Logger.errlog.log("VimeoIsADoucheCopter got bad response 5 times!"+
|
||||||
|
" Giving up.");
|
||||||
|
setImmediate(function () {
|
||||||
|
cb({});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setImmediate(function () {
|
||||||
|
inner();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logger.errlog.log("Vimeo workaround error: ");
|
||||||
|
Logger.errlog.log(e);
|
||||||
|
Logger.errlog.log(data);
|
||||||
|
setImmediate(function () {
|
||||||
|
cb({});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
http.get(options, function (res) {
|
||||||
|
res.setEncoding("utf-8");
|
||||||
|
var buffer = "";
|
||||||
|
|
||||||
|
res.on("data", function (data) {
|
||||||
|
buffer += data;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
res.on("end", function () {
|
||||||
|
parse(buffer);
|
||||||
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
http.get(options, function (res) {
|
inner();
|
||||||
res.setEncoding("utf-8");
|
|
||||||
var buffer = "";
|
|
||||||
|
|
||||||
res.on("data", function (data) {
|
|
||||||
buffer += data;
|
|
||||||
});
|
|
||||||
|
|
||||||
res.on("end", function () {
|
|
||||||
parse(buffer);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -1034,12 +1034,28 @@ Callbacks = {
|
||||||
$("#ytapiplayer_wrapper").remove();
|
$("#ytapiplayer_wrapper").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.type === "vi" && data.direct && data.direct.sd) {
|
/*
|
||||||
|
VIMEO SIMULATOR 2014
|
||||||
|
|
||||||
|
Vimeo decided to block my domain. After repeated emails, they refused to
|
||||||
|
unblock it. Rather than give in to their demands, there is a serverside
|
||||||
|
option which extracts direct links to the h264 encoded MP4 video files.
|
||||||
|
These files can be loaded in a custom player to allow Vimeo playback without
|
||||||
|
triggering their dumb API domain block.
|
||||||
|
|
||||||
|
It's a little bit hacky, but my only other option is to keep buying new
|
||||||
|
domains every time one gets blocked. No thanks to Vimeo, who were of no help
|
||||||
|
and unwilling to compromise on the issue.
|
||||||
|
*/
|
||||||
|
if (NO_VIMEO && data.type === "vi" && data.direct && data.direct.sd) {
|
||||||
|
// For browsers that don't support native h264 playback
|
||||||
if (USEROPTS.no_h264) {
|
if (USEROPTS.no_h264) {
|
||||||
data.type = "jw";
|
data.type = "jw";
|
||||||
} else {
|
} else {
|
||||||
data.type = "rv";
|
data.type = "rv";
|
||||||
}
|
}
|
||||||
|
// Right now only plays standard definition.
|
||||||
|
// In the future, I may add a quality selector for mobile/standard/HD
|
||||||
data.url = data.direct.sd.url;
|
data.url = data.direct.sd.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,8 @@ var USEROPTS = {
|
||||||
var VOLUME = parseFloat(getOrDefault("volume", 1));
|
var VOLUME = parseFloat(getOrDefault("volume", 1));
|
||||||
|
|
||||||
var NO_WEBSOCKETS = USEROPTS.altsocket;
|
var NO_WEBSOCKETS = USEROPTS.altsocket;
|
||||||
|
// Change this to include your own domain if you enable Vimeo fallback
|
||||||
|
var NO_VIMEO = Boolean(location.host.match("cytu.be"));
|
||||||
|
|
||||||
var Rank = {
|
var Rank = {
|
||||||
Guest: 0,
|
Guest: 0,
|
||||||
|
|
Loading…
Reference in a new issue