diff --git a/lib/get-info.js b/lib/get-info.js index 0bff86ac..572aa298 100644 --- a/lib/get-info.js +++ b/lib/get-info.js @@ -96,7 +96,7 @@ var Getters = { callback("HTTP " + status, null); return; } - + var buffer = data; try { data = JSON.parse(data); @@ -339,6 +339,11 @@ var Getters = { callback("Invalid ID", null); return; } + + if (Config.get("vimeo-oauth.enabled")) { + return Getters.vi_oauth(id, callback); + } + var options = { host: "vimeo.com", 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 */ dm: function (id, callback) { // Dailymotion's API is an example of an API done right @@ -658,7 +684,7 @@ var Getters = { var title = js[0].title; var seconds = js[1].videodetails.duration / 1000; var med = new Media(id, title, seconds, "gd"); - + var fv = js[1].videoplay.flashVars; var fvstr = ""; for (var k in fv) {