sirlantis-vimeo 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +18 -0
- data/LICENSE +20 -0
- data/Manifest.txt +27 -0
- data/README.rdoc +171 -0
- data/Rakefile +12 -0
- data/VERSION.yml +4 -0
- data/lib/vimeo.rb +11 -0
- data/lib/vimeo/advanced.rb +11 -0
- data/lib/vimeo/advanced/auth.rb +36 -0
- data/lib/vimeo/advanced/base.rb +67 -0
- data/lib/vimeo/advanced/contact.rb +18 -0
- data/lib/vimeo/advanced/group.rb +19 -0
- data/lib/vimeo/advanced/person.rb +105 -0
- data/lib/vimeo/advanced/test.rb +40 -0
- data/lib/vimeo/advanced/upload.rb +68 -0
- data/lib/vimeo/advanced/video.rb +321 -0
- data/lib/vimeo/simple.rb +13 -0
- data/lib/vimeo/simple/activity.rb +27 -0
- data/lib/vimeo/simple/album.rb +17 -0
- data/lib/vimeo/simple/base.rb +12 -0
- data/lib/vimeo/simple/channel.rb +17 -0
- data/lib/vimeo/simple/clip.rb +12 -0
- data/lib/vimeo/simple/group.rb +22 -0
- data/lib/vimeo/simple/user.rb +62 -0
- data/test/advanced/test_upload.rb +37 -0
- data/test/test_helper.rb +3 -0
- data/vimeo.gemspec +40 -0
- metadata +114 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
module Vimeo
|
2
|
+
module Advanced
|
3
|
+
|
4
|
+
class Test < Vimeo::Advanced::Base
|
5
|
+
# An echo test. Echoes all parameters.
|
6
|
+
# Options can be anything except method, api_key,
|
7
|
+
# and api_sig -- if any of these options are
|
8
|
+
# present they will be overwritten by the proper
|
9
|
+
# values.
|
10
|
+
def echo(options={})
|
11
|
+
options.merge!(:method => "vimeo.test.echo")
|
12
|
+
api_sig = generate_api_sig options
|
13
|
+
options.merge!(:api_sig => api_sig)
|
14
|
+
self.class.post("/api/rest", :query => options)
|
15
|
+
end
|
16
|
+
|
17
|
+
# A null test.
|
18
|
+
def null(auth_token)
|
19
|
+
sig_options = {
|
20
|
+
:auth_token => auth_token,
|
21
|
+
:method => "vimeo.test.null"
|
22
|
+
}
|
23
|
+
|
24
|
+
make_request sig_options
|
25
|
+
end
|
26
|
+
|
27
|
+
# Tests if the user associated to this token
|
28
|
+
# is able to make authenticated calls.
|
29
|
+
def login(auth_token)
|
30
|
+
sig_options = {
|
31
|
+
:auth_token => auth_token,
|
32
|
+
:method => "vimeo.test.login"
|
33
|
+
}
|
34
|
+
|
35
|
+
make_request sig_options
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end # Advanced
|
40
|
+
end # Vimeo
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'webrick/httputils'
|
2
|
+
require 'curl'
|
3
|
+
|
4
|
+
|
5
|
+
module Vimeo
|
6
|
+
module Advanced
|
7
|
+
|
8
|
+
class Upload < Vimeo::Advanced::Base
|
9
|
+
|
10
|
+
def get_upload_ticket(auth_token)
|
11
|
+
sig_options = {
|
12
|
+
:auth_token => auth_token,
|
13
|
+
:method => "vimeo.videos.upload.getTicket"
|
14
|
+
}
|
15
|
+
|
16
|
+
make_request sig_options
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_upload_status(ticket_id, auth_token)
|
20
|
+
sig_options = {
|
21
|
+
:ticket_id => ticket_id,
|
22
|
+
:auth_token => auth_token,
|
23
|
+
:method => "vimeo.videos.checkUploadStatus"
|
24
|
+
}
|
25
|
+
|
26
|
+
make_request sig_options
|
27
|
+
end
|
28
|
+
|
29
|
+
def confirm_upload(auth_token, ticket_id, json_manifest)
|
30
|
+
sig_options = {
|
31
|
+
:auth_token => auth_token,
|
32
|
+
:ticket_id => ticket_id,
|
33
|
+
:method => "vimeo.videos.upload.confirm"
|
34
|
+
}
|
35
|
+
api_sig = generate_api_sig(sig_options)
|
36
|
+
puts "/api/rest/v2/?#{query(sig_options, api_sig).to_params}"
|
37
|
+
self.class.post "/api/rest/v2/", :body => query(sig_options.merge(:json_manifest => json_manifest), api_sig)
|
38
|
+
end
|
39
|
+
|
40
|
+
###
|
41
|
+
# Upload +file+ to vimeo with +ticket_id+ and +auth_token+
|
42
|
+
def upload file, ticket_id, end_point, auth_token
|
43
|
+
params = {
|
44
|
+
:auth_token => auth_token,
|
45
|
+
:ticket_id => ticket_id
|
46
|
+
}
|
47
|
+
params[:api_sig] = generate_api_sig params
|
48
|
+
|
49
|
+
c = Curl::Easy.new(end_point)
|
50
|
+
c.multipart_form_post = true
|
51
|
+
c.http_post(
|
52
|
+
*(params.map { |k,v| Curl::PostField.content(k.to_s, v) } +
|
53
|
+
[Curl::PostField.file('file_data', file)])
|
54
|
+
)
|
55
|
+
{:files => [{:md5 => c.body_str}]}.to_json
|
56
|
+
end
|
57
|
+
|
58
|
+
def signature_for_file_upload(ticket_id, auth_token)
|
59
|
+
sig_options = {
|
60
|
+
:ticket_id => ticket_id,
|
61
|
+
:auth_token => auth_token
|
62
|
+
}
|
63
|
+
generate_api_sig sig_options
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end # Advanced
|
68
|
+
end # Vimeo
|
@@ -0,0 +1,321 @@
|
|
1
|
+
module Vimeo
|
2
|
+
module Advanced
|
3
|
+
|
4
|
+
class Video < Vimeo::Advanced::Base
|
5
|
+
|
6
|
+
def get_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0 })
|
7
|
+
sig_options = {
|
8
|
+
:user_id => user_id,
|
9
|
+
:page => options[:page],
|
10
|
+
:per_page => options[:per_page],
|
11
|
+
:fullResponse => options[:full_response],
|
12
|
+
:method => "vimeo.videos.getList"
|
13
|
+
}
|
14
|
+
|
15
|
+
make_request sig_options
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_uploaded_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
19
|
+
sig_options = {
|
20
|
+
:user_id => user_id,
|
21
|
+
:page => options[:page],
|
22
|
+
:per_page => options[:per_page],
|
23
|
+
:fullResponse => options[:full_response],
|
24
|
+
:auth_token => options[:auth_token],
|
25
|
+
:method => "vimeo.videos.getUploadedList"
|
26
|
+
}
|
27
|
+
|
28
|
+
make_request sig_options
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_appears_in_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
32
|
+
sig_options = {
|
33
|
+
:user_id => user_id,
|
34
|
+
:page => options[:page],
|
35
|
+
:per_page => options[:per_page],
|
36
|
+
:fullResponse => options[:full_response],
|
37
|
+
:method => "vimeo.videos.getAppearsInList"
|
38
|
+
}
|
39
|
+
|
40
|
+
make_request sig_options
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_subscriptions_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
44
|
+
sig_options = {
|
45
|
+
:user_id => user_id,
|
46
|
+
:page => options[:page],
|
47
|
+
:per_page => options[:per_page],
|
48
|
+
:fullResponse => options[:full_response],
|
49
|
+
:auth_token => options[:auth_token],
|
50
|
+
:method => "vimeo.videos.getSubscriptionsList"
|
51
|
+
}
|
52
|
+
|
53
|
+
make_request sig_options
|
54
|
+
end
|
55
|
+
|
56
|
+
def get_list_by_tag(tag, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
57
|
+
user_id = options[:user_id]
|
58
|
+
|
59
|
+
sig_options = {
|
60
|
+
:tag => tag,
|
61
|
+
:page => options[:page],
|
62
|
+
:per_page => options[:per_page],
|
63
|
+
:fullResponse => options[:full_response],
|
64
|
+
:auth_token => options[:auth_token],
|
65
|
+
:method => "vimeo.videos.getListByTag"
|
66
|
+
}
|
67
|
+
sig_options.merge! :user_id => user_id if !user_id.nil?
|
68
|
+
|
69
|
+
make_request sig_options
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_like_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
73
|
+
sig_options = {
|
74
|
+
:user_id => user_id,
|
75
|
+
:page => options[:page],
|
76
|
+
:per_page => options[:per_page],
|
77
|
+
:fullResponse => options[:full_response],
|
78
|
+
:auth_token => options[:auth_token],
|
79
|
+
:method => "vimeo.videos.getLikeList"
|
80
|
+
}
|
81
|
+
|
82
|
+
make_request sig_options
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_contacts_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
86
|
+
sig_options = {
|
87
|
+
:user_id => user_id,
|
88
|
+
:page => options[:page],
|
89
|
+
:per_page => options[:per_page],
|
90
|
+
:fullResponse => options[:full_response],
|
91
|
+
:auth_token => options[:auth_token],
|
92
|
+
:method => "vimeo.videos.getContactsList"
|
93
|
+
}
|
94
|
+
|
95
|
+
make_request sig_options
|
96
|
+
end
|
97
|
+
|
98
|
+
def get_contacts_like_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
99
|
+
sig_options = {
|
100
|
+
:user_id => user_id,
|
101
|
+
:page => options[:page],
|
102
|
+
:per_page => options[:per_page],
|
103
|
+
:fullResponse => options[:full_response],
|
104
|
+
:auth_token => options[:auth_token],
|
105
|
+
:method => "vimeo.videos.getContactsLikeList"
|
106
|
+
}
|
107
|
+
|
108
|
+
make_request sig_options
|
109
|
+
end
|
110
|
+
|
111
|
+
def search(q, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
|
112
|
+
user_id = options[:user_id]
|
113
|
+
contacts_only = options[:contacts_only]
|
114
|
+
|
115
|
+
sig_options = {
|
116
|
+
:query => q,
|
117
|
+
:page => options[:page],
|
118
|
+
:per_page => options[:per_page],
|
119
|
+
:fullResponse => options[:full_response],
|
120
|
+
:auth_token => options[:auth_token],
|
121
|
+
:method => "vimeo.videos.search"
|
122
|
+
}
|
123
|
+
sig_options.merge! :user_id => user_id if !user_id.nil?
|
124
|
+
sig_options.merge! :contacts_only => contacts_only if !contacts_only.nil?
|
125
|
+
|
126
|
+
make_request sig_options
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_info(video_id, auth_token=nil)
|
130
|
+
sig_options = {
|
131
|
+
:video_id => video_id,
|
132
|
+
:auth_token => auth_token,
|
133
|
+
:method => "vimeo.videos.getInfo"
|
134
|
+
}
|
135
|
+
|
136
|
+
make_request sig_options
|
137
|
+
end
|
138
|
+
|
139
|
+
def delete(video_id, auth_token)
|
140
|
+
sig_options = {
|
141
|
+
:video_id => video_id,
|
142
|
+
:auth_token => auth_token,
|
143
|
+
:method => "vimeo.videos.delete"
|
144
|
+
}
|
145
|
+
|
146
|
+
make_request sig_options
|
147
|
+
end
|
148
|
+
|
149
|
+
def get_thumbnail_url(video_id)
|
150
|
+
sig_options = {
|
151
|
+
:video_id => video_id,
|
152
|
+
:method => "vimeo.videos.getThumbnailUrls"
|
153
|
+
}
|
154
|
+
|
155
|
+
make_request sig_options
|
156
|
+
end
|
157
|
+
|
158
|
+
def set_title(video_id, title, auth_token)
|
159
|
+
sig_options = {
|
160
|
+
:video_id => video_id,
|
161
|
+
:title => title,
|
162
|
+
:auth_token => auth_token,
|
163
|
+
:method => "vimeo.videos.setTitle"
|
164
|
+
}
|
165
|
+
|
166
|
+
make_request sig_options
|
167
|
+
end
|
168
|
+
|
169
|
+
def set_caption(video_id, caption, auth_token)
|
170
|
+
sig_options = {
|
171
|
+
:video_id => video_id,
|
172
|
+
:caption => caption,
|
173
|
+
:auth_token => auth_token,
|
174
|
+
:method => "vimeo.videos.setCaption"
|
175
|
+
}
|
176
|
+
|
177
|
+
make_request sig_options
|
178
|
+
end
|
179
|
+
|
180
|
+
def set_favorite(video_id, favorite, auth_token)
|
181
|
+
f = favorite ? true : false
|
182
|
+
|
183
|
+
sig_options = {
|
184
|
+
:video_id => video_id,
|
185
|
+
:favorite => f,
|
186
|
+
:auth_token => auth_token,
|
187
|
+
:method => "vimeo.videos.setFavorite"
|
188
|
+
}
|
189
|
+
|
190
|
+
make_request sig_options
|
191
|
+
end
|
192
|
+
|
193
|
+
def add_tags(video_id, tags, auth_token)
|
194
|
+
sig_options = {
|
195
|
+
:video_id => video_id,
|
196
|
+
:tags => tags,
|
197
|
+
:auth_token => auth_token,
|
198
|
+
:method => "vimeo.videos.addTags"
|
199
|
+
}
|
200
|
+
|
201
|
+
make_request sig_options
|
202
|
+
end
|
203
|
+
|
204
|
+
def remove_tag(video_id, tag_id, auth_token)
|
205
|
+
sig_options = {
|
206
|
+
:video_id => video_id,
|
207
|
+
:tag_id => tag_id,
|
208
|
+
:auth_token => auth_token,
|
209
|
+
:method => "vimeo.videos.removeTag"
|
210
|
+
}
|
211
|
+
|
212
|
+
make_request sig_options
|
213
|
+
end
|
214
|
+
|
215
|
+
def clear_tags(video_id, auth_token)
|
216
|
+
sig_options = {
|
217
|
+
:video_id => video_id,
|
218
|
+
:auth_token => auth_token,
|
219
|
+
:method => "vimeo.videos.clearTags"
|
220
|
+
}
|
221
|
+
|
222
|
+
make_request sig_options
|
223
|
+
end
|
224
|
+
|
225
|
+
def add_cast(video_id, user_id, auth_token, options={})
|
226
|
+
role = options[:role]
|
227
|
+
|
228
|
+
sig_options = {
|
229
|
+
:video_id => video_id,
|
230
|
+
:user_id => user_id,
|
231
|
+
:auth_token => auth_token,
|
232
|
+
:method => "vimeo.videos.addCast"
|
233
|
+
}
|
234
|
+
sig_options.merge! :role => role unless role.nil?
|
235
|
+
|
236
|
+
make_request sig_options
|
237
|
+
end
|
238
|
+
|
239
|
+
def get_cast(video_id, auth_token=nil)
|
240
|
+
sig_options = {
|
241
|
+
:video_id => video_id,
|
242
|
+
:auth_token => auth_token,
|
243
|
+
:method => "vimeo.videos.getCast"
|
244
|
+
}
|
245
|
+
|
246
|
+
make_request sig_options
|
247
|
+
end
|
248
|
+
|
249
|
+
def remove_cast(video_id, user_id, auth_token)
|
250
|
+
sig_options = {
|
251
|
+
:video_id => video_id,
|
252
|
+
:user_id => user_id,
|
253
|
+
:auth_token => auth_token,
|
254
|
+
:method => "vimeo.videos.removeCast"
|
255
|
+
}
|
256
|
+
|
257
|
+
make_request sig_options
|
258
|
+
end
|
259
|
+
|
260
|
+
# TODO: Add ability to specify users
|
261
|
+
def set_privacy(video_id, privacy, auth_token)
|
262
|
+
sig_options = {
|
263
|
+
:video_id => video_id,
|
264
|
+
:privacy => privacy,
|
265
|
+
:auth_token => auth_token,
|
266
|
+
:method => "vimeo.videos.setPrivacy"
|
267
|
+
}
|
268
|
+
|
269
|
+
make_request sig_options
|
270
|
+
end
|
271
|
+
|
272
|
+
def get_comments_list(video_id)
|
273
|
+
sig_options = {
|
274
|
+
:video_id => video_id,
|
275
|
+
:method => "vimeo.videos.comments.getList"
|
276
|
+
}
|
277
|
+
|
278
|
+
make_request sig_options
|
279
|
+
end
|
280
|
+
|
281
|
+
def add_comment(video_id, comment_text, auth_token, options={})
|
282
|
+
reply_to_comment_id = options[:reply_to_comment_id]
|
283
|
+
|
284
|
+
sig_options = {
|
285
|
+
:video_id => video_id,
|
286
|
+
:comment_text => comment_text,
|
287
|
+
:auth_token => auth_token,
|
288
|
+
:method => "vimeo.videos.comments.addComment"
|
289
|
+
}
|
290
|
+
sig_options.merge! :reply_to_comment_id => reply_to_comment_id unless reply_to_comment_id.nil?
|
291
|
+
|
292
|
+
make_request sig_options
|
293
|
+
end
|
294
|
+
|
295
|
+
def delete_comment(video_id, comment_id, auth_token)
|
296
|
+
sig_options = {
|
297
|
+
:video_id => video_id,
|
298
|
+
:comment_id => comment_id,
|
299
|
+
:auth_token => auth_token,
|
300
|
+
:method => "vimeo.videos.comments.deleteComment"
|
301
|
+
}
|
302
|
+
|
303
|
+
make_request sig_options
|
304
|
+
end
|
305
|
+
|
306
|
+
def edit_comment(video_id, comment_id, comment_text, auth_token)
|
307
|
+
sig_options = {
|
308
|
+
:video_id => video_id,
|
309
|
+
:comment_id => comment_id,
|
310
|
+
:comment_text => comment_text,
|
311
|
+
:auth_token => auth_token,
|
312
|
+
:method => "vimeo.videos.comments.editComment"
|
313
|
+
}
|
314
|
+
|
315
|
+
make_request sig_options
|
316
|
+
end
|
317
|
+
|
318
|
+
end
|
319
|
+
|
320
|
+
end # Advanced
|
321
|
+
end # Vimeo
|
data/lib/vimeo/simple.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'vimeo/simple/base'
|
2
|
+
require 'vimeo/simple/activity'
|
3
|
+
require 'vimeo/simple/album'
|
4
|
+
require 'vimeo/simple/channel'
|
5
|
+
require 'vimeo/simple/clip'
|
6
|
+
require 'vimeo/simple/group'
|
7
|
+
require 'vimeo/simple/user'
|
8
|
+
|
9
|
+
module Vimeo
|
10
|
+
module Simple
|
11
|
+
|
12
|
+
end # Simple
|
13
|
+
end # Vimeo
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Vimeo
|
2
|
+
module Simple
|
3
|
+
|
4
|
+
class Activity < Vimeo::Simple::Base
|
5
|
+
def self.user_did(username)
|
6
|
+
get("/activity/#{username}/user_did.json")
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.happened_to_user(username)
|
10
|
+
get("/activity/#{username}/happened_to_user.json")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.contacts_did(username)
|
14
|
+
get("/activity/#{username}/contacts_did.json")
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.happened_to_contacts(username)
|
18
|
+
get("/activity/#{username}/happened_to_contacts.json")
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.everyone_did(username)
|
22
|
+
get("/activity/#{username}/everyone_did.json")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end # Simple
|
27
|
+
end # Vimeo
|