Start working on vimeo advanced api support

This commit is contained in:
Calvin Montgomery 2014-04-04 11:37:30 -05:00
parent 92e05b96c8
commit 4577a2dbd5

View file

@ -96,7 +96,7 @@ var Getters = {
callback("HTTP " + status, null); callback("HTTP " + status, null);
return; return;
} }
var buffer = data; var buffer = data;
try { try {
data = JSON.parse(data); data = JSON.parse(data);
@ -339,6 +339,11 @@ var Getters = {
callback("Invalid ID", null); callback("Invalid ID", null);
return; return;
} }
if (Config.get("vimeo-oauth.enabled")) {
return Getters.vi_oauth(id, callback);
}
var options = { var options = {
host: "vimeo.com", host: "vimeo.com",
port: 443, port: 443,
@ -380,6 +385,27 @@ var Getters = {
}); });
}, },
vi_oauth: function (id, callback) {
var OAuth = require("oauth");
var oa = new OAuth.OAuth(
"https://vimeo.com/oauth/request_token",
"https://vimeo.com/oauth/access_token",
Config.get("vimeo-oauth.consumer-key"),
Config.get("vimeo-oauth.secret"),
"1.0",
null,
"HMAC-SHA1"
);
oa.get("https://vimeo.com/api/rest/v2?format=json" +
"&method=vimeo.videos.getInfo&video_id=" + id,
null,
null,
function (err, data, res) {
console.log(err, data);
});
},
/* dailymotion.com */ /* dailymotion.com */
dm: function (id, callback) { dm: function (id, callback) {
// Dailymotion's API is an example of an API done right // Dailymotion's API is an example of an API done right
@ -658,7 +684,7 @@ var Getters = {
var title = js[0].title; var title = js[0].title;
var seconds = js[1].videodetails.duration / 1000; var seconds = js[1].videodetails.duration / 1000;
var med = new Media(id, title, seconds, "gd"); var med = new Media(id, title, seconds, "gd");
var fv = js[1].videoplay.flashVars; var fv = js[1].videoplay.flashVars;
var fvstr = ""; var fvstr = "";
for (var k in fv) { for (var k in fv) {