-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimeo.js
96 lines (92 loc) · 2.93 KB
/
vimeo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Generated by CoffeeScript 1.3.3
(function() {
var qs, request;
request = require('request');
qs = require('querystring');
exports.app = function(config) {
var accUrl, appId, appSecret, authUrl, callbackUrl, reqUrl, root;
root = 'https://vimeo.com/api/rest/v2?format=json';
reqUrl = 'https://vimeo.com/oauth/request_token';
authUrl = 'https://vimeo.com/oauth/authorize?oauth_token=';
accUrl = 'https://vimeo.com/oauth/access_token';
callbackUrl = config.CALLBACK_URL;
appId = config.APP_ID;
appSecret = config.APP_SECRET;
return {
requestToken: function(callback) {
var params, url;
params = {
callback: callbackUrl,
consumer_key: appId,
consumer_secret: appSecret
};
url = reqUrl;
return request.post({
url: url,
oauth: params
}, function(err, res, body) {
body = qs.parse(body);
body.redirect = authUrl + body.oauth_token;
return callback(body);
});
},
getAccToken: function(params, callback) {
params.consumer_key = appId;
params.consumer_secret = appSecret;
return request.post({
url: accUrl,
oauth: params
}, function(err, res, body) {
body = qs.parse(body);
console.log(body);
return callback(body);
});
},
getUserInfo: function(params, callback) {
params.consumer_key = appId;
params.consumer_secret = appSecret;
console.log(params);
return request.post({
url: root + '&method=vimeo.people.getInfo',
oauth: params
}, function(err, res, body) {
body = JSON.parse(body);
return callback(body);
});
},
getAllVideos: function(params, callback) {
params.consumer_key = appId;
params.consumer_secret = appSecret;
return request.post({
url: root + '&method=vimeo.videos.getAll',
oauth: params
}, function(err, res, body) {
body = JSON.parse(body);
return callback(body);
});
},
getThumbnailUrls: function(params, id, callback) {
params.consumer_key = appId;
params.consumer_secret = appSecret;
return request.post({
url: root + '&method=vimeo.videos.getThumbnailUrls&video_id=' + id,
oauth: params
}, function(err, res, body) {
body = JSON.parse(body);
return callback(body);
});
},
getVideoInfo: function(params, videoid, callback) {
params.consumer_key = appId;
params.consumer_secret = appSecret;
return request.post({
url: root + '&method=vimeo.videos.getInfo&video_id=' + videoid,
oauth: params
}, function(err, res, body) {
body = JSON.parse(body);
return callback(body.video[0]);
});
}
};
};
}).call(this);