mirror of https://github.com/calzoneman/sync.git
Merge pull request #342 from calzoneman/vimeo_oauth
Add support for Vimeo's OAuth API
This commit is contained in:
commit
a141e3dafb
|
@ -97,6 +97,16 @@ aliases:
|
|||
# Workaround for Vimeo blocking my domain
|
||||
vimeo-workaround: false
|
||||
|
||||
# OPTIONAL: Use Vimeo's OAuth API instead of the anonymous API.
|
||||
# This allows you to add private videos that have embedding enabled.
|
||||
# See https://developer.vimeo.com/apps/new to register for this API.
|
||||
# Note that in order to use this feature you must agree to Vimeo's
|
||||
# Terms of Service and License Agreement.
|
||||
vimeo-oauth:
|
||||
enabled: false
|
||||
consumer-key: ''
|
||||
secret: ''
|
||||
|
||||
# Regular expressions for defining reserved user and channel names and page titles
|
||||
# The list of regular expressions will be joined with an OR, and compared without
|
||||
# case sensitivity.
|
||||
|
|
|
@ -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,50 @@ 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) {
|
||||
if (err) {
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
|
||||
if (data.stat !== "ok") {
|
||||
return callback(data.err.msg, null);
|
||||
}
|
||||
|
||||
var video = data.video[0];
|
||||
|
||||
if (video.embed_privacy !== "anywhere") {
|
||||
return callback("Embedding disabled", null);
|
||||
}
|
||||
|
||||
var id = video.id;
|
||||
var seconds = parseInt(video.duration);
|
||||
var title = video.title;
|
||||
callback(null, new Media(id, title, seconds, "vi"));
|
||||
} catch (e) {
|
||||
callback("Error handling Vimeo response", null);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/* dailymotion.com */
|
||||
dm: function (id, callback) {
|
||||
// Dailymotion's API is an example of an API done right
|
||||
|
@ -658,7 +707,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) {
|
||||
|
|
|
@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
const VERSION = "3.0.0-RC2";
|
||||
const VERSION = "3.0.1";
|
||||
var singleton = null;
|
||||
var Config = require("./config");
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "3.0.0-RC2",
|
||||
"version": "3.0.1",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
@ -15,6 +15,7 @@
|
|||
"nodemailer": "~0.6.0",
|
||||
"cookie": "~0.1.0",
|
||||
"yamljs": "~0.1.4",
|
||||
"express-minify": "0.0.7"
|
||||
"express-minify": "0.0.7",
|
||||
"oauth": "^0.9.11"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue