tenderlove-vimeo 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,322 @@
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, size=100)
150
+ sig_options = {
151
+ :video_id => video_id,
152
+ :size => size,
153
+ :method => "vimeo.videos.getThumbnailUrl"
154
+ }
155
+
156
+ make_request sig_options
157
+ end
158
+
159
+ def set_title(video_id, title, auth_token)
160
+ sig_options = {
161
+ :video_id => video_id,
162
+ :title => title,
163
+ :auth_token => auth_token,
164
+ :method => "vimeo.videos.setTitle"
165
+ }
166
+
167
+ make_request sig_options
168
+ end
169
+
170
+ def set_caption(video_id, caption, auth_token)
171
+ sig_options = {
172
+ :video_id => video_id,
173
+ :caption => caption,
174
+ :auth_token => auth_token,
175
+ :method => "vimeo.videos.setCaption"
176
+ }
177
+
178
+ make_request sig_options
179
+ end
180
+
181
+ def set_favorite(video_id, favorite, auth_token)
182
+ f = favorite ? true : false
183
+
184
+ sig_options = {
185
+ :video_id => video_id,
186
+ :favorite => f,
187
+ :auth_token => auth_token,
188
+ :method => "vimeo.videos.setFavorite"
189
+ }
190
+
191
+ make_request sig_options
192
+ end
193
+
194
+ def add_tags(video_id, tags, auth_token)
195
+ sig_options = {
196
+ :video_id => video_id,
197
+ :tags => tags,
198
+ :auth_token => auth_token,
199
+ :method => "vimeo.videos.addTags"
200
+ }
201
+
202
+ make_request sig_options
203
+ end
204
+
205
+ def remove_tag(video_id, tag_id, auth_token)
206
+ sig_options = {
207
+ :video_id => video_id,
208
+ :tag_id => tag_id,
209
+ :auth_token => auth_token,
210
+ :method => "vimeo.videos.removeTag"
211
+ }
212
+
213
+ make_request sig_options
214
+ end
215
+
216
+ def clear_tags(video_id, auth_token)
217
+ sig_options = {
218
+ :video_id => video_id,
219
+ :auth_token => auth_token,
220
+ :method => "vimeo.videos.clearTags"
221
+ }
222
+
223
+ make_request sig_options
224
+ end
225
+
226
+ def add_cast(video_id, user_id, auth_token, options={})
227
+ role = options[:role]
228
+
229
+ sig_options = {
230
+ :video_id => video_id,
231
+ :user_id => user_id,
232
+ :auth_token => auth_token,
233
+ :method => "vimeo.videos.addCast"
234
+ }
235
+ sig_options.merge! :role => role unless role.nil?
236
+
237
+ make_request sig_options
238
+ end
239
+
240
+ def get_cast(video_id, auth_token=nil)
241
+ sig_options = {
242
+ :video_id => video_id,
243
+ :auth_token => auth_token,
244
+ :method => "vimeo.videos.getCast"
245
+ }
246
+
247
+ make_request sig_options
248
+ end
249
+
250
+ def remove_cast(video_id, user_id, auth_token)
251
+ sig_options = {
252
+ :video_id => video_id,
253
+ :user_id => user_id,
254
+ :auth_token => auth_token,
255
+ :method => "vimeo.videos.removeCast"
256
+ }
257
+
258
+ make_request sig_options
259
+ end
260
+
261
+ # TODO: Add ability to specify users
262
+ def set_privacy(video_id, privacy, auth_token)
263
+ sig_options = {
264
+ :video_id => video_id,
265
+ :privacy => privacy,
266
+ :auth_token => auth_token,
267
+ :method => "vimeo.videos.setPrivacy"
268
+ }
269
+
270
+ make_request sig_options
271
+ end
272
+
273
+ def get_comments_list(video_id)
274
+ sig_options = {
275
+ :video_id => video_id,
276
+ :method => "vimeo.videos.comments.getList"
277
+ }
278
+
279
+ make_request sig_options
280
+ end
281
+
282
+ def add_comment(video_id, comment_text, auth_token, options={})
283
+ reply_to_comment_id = options[:reply_to_comment_id]
284
+
285
+ sig_options = {
286
+ :video_id => video_id,
287
+ :comment_text => comment_text,
288
+ :auth_token => auth_token,
289
+ :method => "vimeo.videos.comments.addComment"
290
+ }
291
+ sig_options.merge! :reply_to_comment_id => reply_to_comment_id unless reply_to_comment_id.nil?
292
+
293
+ make_request sig_options
294
+ end
295
+
296
+ def delete_comment(video_id, comment_id, auth_token)
297
+ sig_options = {
298
+ :video_id => video_id,
299
+ :comment_id => comment_id,
300
+ :auth_token => auth_token,
301
+ :method => "vimeo.videos.comments.deleteComment"
302
+ }
303
+
304
+ make_request sig_options
305
+ end
306
+
307
+ def edit_comment(video_id, comment_id, comment_text, auth_token)
308
+ sig_options = {
309
+ :video_id => video_id,
310
+ :comment_id => comment_id,
311
+ :comment_text => comment_text,
312
+ :auth_token => auth_token,
313
+ :method => "vimeo.videos.comments.editComment"
314
+ }
315
+
316
+ make_request sig_options
317
+ end
318
+
319
+ end
320
+
321
+ end # Advanced
322
+ end # Vimeo
@@ -0,0 +1,11 @@
1
+ require 'vimeo/advanced/base'
2
+ require 'vimeo/advanced/auth'
3
+ require 'vimeo/advanced/test'
4
+ require 'vimeo/advanced/video'
5
+ require 'vimeo/advanced/upload'
6
+
7
+ module Vimeo
8
+ module Advanced
9
+
10
+ end
11
+ end
@@ -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
@@ -0,0 +1,17 @@
1
+ module Vimeo
2
+ module Simple
3
+
4
+ class Album < Vimeo::Simple::Base
5
+ # Returns this album's clips.
6
+ def self.clips(album_id)
7
+ get("/album/#{album_id}/clips.json")
8
+ end
9
+
10
+ # Returns this album's information.
11
+ def self.info(album_id)
12
+ get("/album/#{album_id}/info.json")
13
+ end
14
+ end
15
+
16
+ end # Simple
17
+ end # Vimeo
@@ -0,0 +1,12 @@
1
+ module Vimeo
2
+ module Simple
3
+
4
+ class Base
5
+ include HTTParty
6
+ base_uri 'vimeo.com/api'
7
+
8
+ # TODO: Format options
9
+ end
10
+
11
+ end # Simple
12
+ end # Vimeo
@@ -0,0 +1,17 @@
1
+ module Vimeo
2
+ module Simple
3
+
4
+ class Channel < Vimeo::Simple::Base
5
+ # Returns this channel's clips.
6
+ def self.clips(channelname)
7
+ get("/channel/#{channelname}/clips.json")
8
+ end
9
+
10
+ # Returns this channel's information.
11
+ def self.info(channelname)
12
+ get("/channel/#{channelname}/info.json")
13
+ end
14
+ end
15
+
16
+ end # Simple
17
+ end # Vimeo
@@ -0,0 +1,12 @@
1
+ module Vimeo
2
+ module Simple
3
+
4
+ class Clip < Vimeo::Simple::Base
5
+ # Returns this clip's information.
6
+ def self.info(video_id)
7
+ get("/clip/#{video_id}.json")
8
+ end
9
+ end
10
+
11
+ end # End Simple
12
+ end # End Vimeo
@@ -0,0 +1,22 @@
1
+ module Vimeo
2
+ module Simple
3
+
4
+ class Group < Vimeo::Simple::Base
5
+ # Returns this group's clips.
6
+ def self.clips(groupname)
7
+ get("/group/#{groupname}/clips.json")
8
+ end
9
+
10
+ # Returns this group's users.
11
+ def self.users(groupname)
12
+ get("/group/#{groupname}/users.json")
13
+ end
14
+
15
+ # Returns this group's information.
16
+ def self.info(groupname)
17
+ get("/group/#{groupname}/info.json")
18
+ end
19
+ end
20
+
21
+ end # Simple
22
+ end # Vimeo
@@ -0,0 +1,62 @@
1
+ module Vimeo
2
+ module Simple
3
+
4
+ class User < Vimeo::Simple::Base
5
+ # Returns this user's information.
6
+ def self.info(username)
7
+ get("/#{username}/info.json")
8
+ end
9
+
10
+ # Returns this user's clips.
11
+ def self.clips(username)
12
+ get("/#{username}/clips.json")
13
+ end
14
+
15
+ # Returns this user's liked clips.
16
+ def self.likes(username)
17
+ get("/#{username}/likes.json")
18
+ end
19
+
20
+ # Returns the clips this user appears in.
21
+ def self.appears_in(username)
22
+ get("/#{username}/appears_in.json")
23
+ end
24
+
25
+ # Returns all clips related to this user.
26
+ def self.all_clips(username)
27
+ get("/#{username}/all_clips.json")
28
+ end
29
+
30
+ # Returns this user's subscriptions.
31
+ def self.subscriptions(username)
32
+ get("/#{username}/subscriptions.json")
33
+ end
34
+
35
+ # Returns this user's albums.
36
+ def self.albums(username)
37
+ get("/#{username}/albums.json")
38
+ end
39
+
40
+ # Returns this user's channels.
41
+ def self.channels(username)
42
+ get("/#{username}/channels.json")
43
+ end
44
+
45
+ # Returns this user's groups.
46
+ def self.groups(username)
47
+ get("/#{username}/groups.json")
48
+ end
49
+
50
+ # Returns this user's contact's clips.
51
+ def self.contacts_clips(username)
52
+ get("/#{username}/contacts_clips.json")
53
+ end
54
+
55
+ # Returns the clips that this user's contact's liked.
56
+ def self.contacts_like(username)
57
+ get("/#{username}/contacts_like.json")
58
+ end
59
+ end
60
+
61
+ end # End Simple
62
+ end # End Vimeo
@@ -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
data/lib/vimeo.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'digest/md5'
4
+ require 'cgi'
5
+
6
+ require 'vimeo/simple'
7
+ require 'vimeo/advanced'
8
+
9
+ module Vimeo
10
+ VERSION = '1.3.0'
11
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+ require 'vimeo/advanced/upload'
3
+
4
+ module Vimeo
5
+ module Advanced
6
+ class UploadTest < ::Test::Unit::TestCase
7
+ class Vimeo::Advanced::Upload
8
+ class HTTP < Struct.new(:host, :port)
9
+ class Post
10
+ def initialize uri
11
+ @uri = uri
12
+ @params = {}
13
+ end
14
+
15
+ def []= k,v
16
+ @params[k] = v
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ def test_upload
23
+ ul = Vimeo::Advanced::Upload.new('a', 'b')
24
+
25
+ def ul.get_upload_ticket *args
26
+ 'foo'
27
+ end
28
+
29
+ def ul.NET
30
+ FakeHTTP
31
+ end
32
+
33
+ ul.upload(__FILE__, 'test', 'testing')
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'vimeo'
data/vimeo.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{vimeo}
5
+ s.version = "1.3.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Matt Hooks"]
9
+ s.date = %q{2009-07-11}
10
+ s.description = %q{}
11
+ s.email = ["matthooks@gmail.com"]
12
+ s.extra_rdoc_files = ["Manifest.txt", "CHANGELOG.rdoc", "README.rdoc"]
13
+ s.files = ["CHANGELOG.rdoc", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "VERSION.yml", "lib/vimeo.rb", "lib/vimeo/advanced.rb", "lib/vimeo/advanced/auth.rb", "lib/vimeo/advanced/base.rb", "lib/vimeo/advanced/contact.rb", "lib/vimeo/advanced/group.rb", "lib/vimeo/advanced/person.rb", "lib/vimeo/advanced/test.rb", "lib/vimeo/advanced/upload.rb", "lib/vimeo/advanced/video.rb", "lib/vimeo/simple.rb", "lib/vimeo/simple/activity.rb", "lib/vimeo/simple/album.rb", "lib/vimeo/simple/base.rb", "lib/vimeo/simple/channel.rb", "lib/vimeo/simple/clip.rb", "lib/vimeo/simple/group.rb", "lib/vimeo/simple/user.rb", "test/advanced/test_upload.rb", "test/test_helper.rb", "vimeo.gemspec"]
14
+ s.homepage = %q{http://github.com/matthooks/vimeo}
15
+ s.rdoc_options = ["--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{vimeo}
18
+ s.rubygems_version = %q{1.3.4}
19
+ s.summary = %q{}
20
+ s.test_files = ["test/advanced/test_upload.rb", "test/test_helper.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_runtime_dependency(%q<jnunemaker-httparty>, [">= 0.2.6"])
28
+ s.add_development_dependency(%q<hoe>, [">= 2.3.2"])
29
+ else
30
+ s.add_dependency(%q<jnunemaker-httparty>, [">= 0.2.6"])
31
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
32
+ end
33
+ else
34
+ s.add_dependency(%q<jnunemaker-httparty>, [">= 0.2.6"])
35
+ s.add_dependency(%q<hoe>, [">= 2.3.2"])
36
+ end
37
+ end