matthooks-vimeo 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,10 @@
1
+ == 0.2.0, released 2009-01-06
2
+
3
+ * Major re-factor of each request method.
4
+ * Separated the simple and advanced APIs into their own modules.
5
+ * Added some documentation.
6
+ * Updated the README.
7
+
8
+ == 0.1.2, released 2008-10-26
9
+
10
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Matt Hooks
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,169 @@
1
+ = Vimeo API Gem
2
+
3
+ This gem implements a full-featured ruby interface for the Vimeo API.
4
+
5
+ Vimeo's API documentation is, in my opinion, pretty poor. I've done my best to implement all the functions that are described {here}[http://vimeo.com/api-docs/advanced-api-docs.html]. There are some extra functions described {here}[http://vimeo.com/api/sandbox], but I can't be 100% sure what the correct parameters are for each method, so I'm going to omit them for the time being.
6
+
7
+ == Install
8
+
9
+ If you haven't already, add github's gem server to your sources:
10
+
11
+ gem sources -a http://gems.github.com
12
+
13
+ Then, it's as easy as:
14
+
15
+ sudo gem install matthooks-vimeo
16
+
17
+ Add the gem plugin to your Rails project by adding the following to your @environment.rb@ file:
18
+
19
+ config.gem "matthooks-vimeo", :lib => "vimeo"
20
+
21
+ == Use
22
+
23
+ There are two modules:
24
+
25
+ Vimeo::Simple
26
+ Vimeo::Advanced
27
+
28
+ == Simple API
29
+
30
+ The wrapper for the Simple API consists of the following classes and methods:
31
+
32
+ === Vimeo::Simple::User
33
+
34
+ Vimeo::Simple::User.info(username)
35
+ Vimeo::Simple::User.clips(username)
36
+ Vimeo::Simple::User.likes(username)
37
+ Vimeo::Simple::User.appears_in(username)
38
+ Vimeo::Simple::User.all_clips(username)
39
+ Vimeo::Simple::User.subscriptions(username)
40
+ Vimeo::Simple::User.albums(username)
41
+ Vimeo::Simple::User.channels(username)
42
+ Vimeo::Simple::User.groups(username)
43
+ Vimeo::Simple::User.contacts_clips(username)
44
+ Vimeo::Simple::User.contacts_like(username)
45
+
46
+ === Vimeo::Simple::Clip
47
+
48
+ Vimeo::Simple::Clip.info(video_id)
49
+
50
+ === Vimeo::Simple::Activity
51
+
52
+ Vimeo::Simple::Activity.user_did(username)
53
+ Vimeo::Simple::Activity.happened_to_user(username)
54
+ Vimeo::Simple::Activity.contacts_did(username)
55
+ Vimeo::Simple::Activity.happened_to_contacts(username)
56
+ Vimeo::Simple::Activity.everyone_did(username)
57
+
58
+ === Vimeo::Simple::Group
59
+
60
+ Vimeo::Simple::Group.clips(groupname)
61
+ Vimeo::Simple::Group.users(groupname)
62
+ Vimeo::Simple::Group.info(groupname)
63
+
64
+ === Vimeo::Simple::Channel
65
+
66
+ Vimeo::Simple::Channel.clips(channelname)
67
+ Vimeo::Simple::Channel.info(channelname)
68
+
69
+ === Vimeo::Simple::Album
70
+
71
+ Vimeo::Simple::Album.clips(album_id)
72
+ Vimeo::Simple::Album.info(album_id)
73
+
74
+ == Advanced API
75
+
76
+ The classes in Vimeo::Advanced must be instantiated with an your application's api key and secret. For example,
77
+
78
+ vimeo_video = Vimeo::Advanced::Video.new("api_key", "secret")
79
+
80
+ Then you can make calls on the instance:
81
+
82
+ vimeo_video.get_list("matthooks", :page => 2, :per_page => 50)
83
+
84
+ The wrapper for the Advanced API consists of the following classes and methods:
85
+
86
+ === Vimeo::Advanced::Auth
87
+
88
+ get_token(frob)
89
+ get_frob
90
+ check_token(auth_token)
91
+
92
+ === Vimeo::Advanced::Test
93
+
94
+ echo(options={})
95
+ null(auth_token)
96
+ login(auth_token)
97
+
98
+ === Vimeo::Advanced::Video
99
+
100
+ get_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0 })
101
+ get_uploaded_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
102
+ get_appears_in_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
103
+ get_subscriptions_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
104
+ get_list_by_tag(tag, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })@
105
+ get_like_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })@
106
+ get_contacts_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
107
+ get_contacts_like_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
108
+ search(q, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
109
+ get_info(video_id, auth_token=nil)
110
+ delete(video_id, auth_token)
111
+ get_thumbnail_url(video_id, size=100)
112
+ set_title(video_id, title, auth_token)
113
+ set_caption(video_id, caption, auth_token)
114
+ set_favorite(video_id, favorite, auth_token)
115
+ add_tags(video_id, tags, auth_token)
116
+ remove_tag(video_id, tag_id, auth_token)
117
+ clear_tags(video_id, auth_token)
118
+ add_cast(video_id, user_id, auth_token, options={})
119
+ get_cast(video_id, auth_token=nil)
120
+ remove_cast(video_id, user_id, auth_token)
121
+ set_privacy(video_id, privacy, auth_token)
122
+ get_comments_list(video_id)
123
+ add_comment(video_id, comment_text, auth_token, options={})
124
+ delete_comment(video_id, comment_id, auth_token)
125
+ edit_comment(video_id, comment_id, comment_text, auth_token)
126
+
127
+ === Vimeo::Advanced::Person
128
+
129
+ find_by_user_name(username)
130
+ find_by_email(find_email)
131
+ get_info(user_id)
132
+ get_portrait_url(user_id, options={})
133
+ add_contact(user_id, auth_token)
134
+ remove_contact(user_id, auth_token)
135
+ get_upload_status(user_id, auth_token)
136
+ add_subscription(user_id, type, auth_token)
137
+ remove_subscription(user_id, type, auth_token)
138
+
139
+ === Vimeo::Advanced::Contact
140
+
141
+ get_list(user_id)
142
+
143
+ === Vimeo::Advanced::Group
144
+
145
+ get_members(group_id)
146
+
147
+ === Vimeo::Advanced::Upload
148
+
149
+ get_upload_ticket(auth_token)
150
+ check_upload_status(ticket_id, auth_token)
151
+
152
+ == Todo
153
+
154
+ * Implement options that allow you to specify a format (xml, json, PHP). Right now this is slightly complicated by the fact that Vimeo returns text/html for json and not application/json, so HTTParty can't auto-detect the content-type.
155
+ * Better initialize method for the advanced api that takes the auth_token into account.
156
+ * Define a method that returns the correct form URL for uploading videos.
157
+ * video_set_privacy needs the ability to specify users.
158
+ * Some methods are not implemented by vimeo or don't seem to work.
159
+ * Input verification? The alternative is to just let vimeo handle it.
160
+ * May need to escape input in several cases
161
+ * More re-factoring.
162
+ * Tests
163
+
164
+ == Thanks to
165
+
166
+ * {HTTParty}[http://github.com/jnunemaker/httparty/tree/master]: Easily one of the best tools I have used since I started using Ruby.
167
+ * {Jeweler}[http://github.com/technicalpickles/jeweler/tree/master]: Great tool for creating gems for github.
168
+
169
+ === Copyright (c) 2008 Matt Hooks. See LICENSE for details.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matthooks-vimeo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Hooks
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-29 00:00:00 -08:00
12
+ date: 2009-01-06 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.2.4
22
+ version: 0.2.6
23
23
  version:
24
24
  description: A full featured Ruby implementation of the Vimeo API.
25
25
  email: matthooks@gmail.com
@@ -27,19 +27,22 @@ executables: []
27
27
 
28
28
  extensions: []
29
29
 
30
- extra_rdoc_files: []
31
-
30
+ extra_rdoc_files:
31
+ - README.rdoc
32
+ - LICENSE
33
+ - CHANGELOG.rdoc
32
34
  files:
33
- - README.textile
34
- - VERSION.yml
35
- - lib/vimeo.rb
36
- - test/test_helper.rb
37
- - test/vimeo_test.rb
38
- has_rdoc: false
35
+ - README.rdoc
36
+ - LICENSE
37
+ - CHANGELOG.rdoc
38
+ has_rdoc: true
39
39
  homepage: http://github.com/matthooks/vimeo
40
40
  post_install_message:
41
- rdoc_options: []
42
-
41
+ rdoc_options:
42
+ - --main
43
+ - README.rdoc
44
+ - --inline-source
45
+ - --charset=UTF-8
43
46
  require_paths:
44
47
  - lib
45
48
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.textile DELETED
@@ -1,79 +0,0 @@
1
- h1. Vimeo API Gem
2
-
3
- This gem implements a full-featured ruby interface for the Vimeo API.
4
-
5
- Vimeo's API documentation is, in my opinion, pretty poor. I've done my best to implement all the functions that are described "here":http://vimeo.com/api-docs/advanced-api-docs.html. There are some extra functions described "here":http://vimeo.com/api/sandbox, but I can't be 100% sure what the correct parameters are for each method, so I'm going to omit them for the time being.
6
-
7
- h2. Install
8
-
9
- If you haven't already, add github's gem server to your sources:
10
-
11
- @gem sources -a http://gems.github.com@
12
-
13
- Then, it's as easy as:
14
-
15
- @sudo gem install matthooks-vimeo@
16
-
17
- Add the gem plugin to your Rails project by adding the following to your @environment.rb@ file:
18
-
19
- @config.gem "matthooks-vimeo", :source => "http://gems.github.com/"@
20
-
21
- h2. Use
22
-
23
- Right now there are two models:
24
-
25
- VimeoSimple and VimeoAdvanced
26
-
27
- h2. VimeoSimple
28
-
29
- VimeoSimple is comprised of class methods:
30
-
31
- * VimeoSimple.user_info(username)
32
- * VimeoSimple.user_clips(username)
33
- * VimeoSimple.user_likes(username)
34
- * VimeoSimple.user_appears_in(username)
35
- * VimeoSimple.user_all_clips(username)
36
- * VimeoSimple.user_subscriptions(username)
37
- * VimeoSimple.user_albums(username)
38
- * VimeoSimple.user_channels(username)
39
- * VimeoSimple.user_groups(username)
40
- * VimeoSimple.user_contacts_clips(username)
41
- * VimeoSimple.user_contacts_like(username)
42
- * VimeoSimple.clip_info(video_id)
43
- * VimeoSimple.activity_user_did(username)
44
- * VimeoSimple.activity_happened_to_user(username)
45
- * VimeoSimple.activity_contacts_did(username)
46
- * VimeoSimple.activity_happened_to_contacts(username)
47
- * VimeoSimple.activity_everyone_did(username)
48
- * VimeoSimple.group_clips(groupname)
49
- * VimeoSimple.group_users(groupname)
50
- * VimeoSimple.group_info(groupname)
51
- * VimeoSimple.channel_clips(channelname)
52
- * VimeoSimple.channel_info(channelname)
53
- * VimeoSimple.album_clips(album_id)
54
- * VimeoSimple.album_info(album_id)
55
-
56
- h2. VimeoAdvanced
57
-
58
- VimeoAdvanced must be instantiated with an your application's api key and secret:
59
-
60
- @v = VimeoAdvanced.new("api_key", "secret")@
61
-
62
- Then you can make calls on the instance:
63
-
64
- @v.videos_get_list(user_id, options)@
65
-
66
- h2. Todo
67
-
68
- * Implement options that allow you to specify a format (xml, json, PHP). Right now this is slightly complicated by the fact that Vimeo returns text/html for json and not application/json, so HTTParty can't auto-detect the content-type.
69
- * Namespaces! Modules! Etc.
70
- * Better initialize method for the advanced api that takes the auth_token into account.
71
- * Define a method that returns the correct form URL for uploading videos.
72
- * video_set_privacy needs the ability to specify users.
73
- * Some methods are not implemented by vimeo or don't seem to work.
74
- * Input verification? The alternative is to just let vimeo handle it.
75
- * May need to escape input in several cases
76
- * There's PLENTY of room to re-factor as there is a ton of duplication and I started passing inputs differently about halfway through.
77
- * Tests
78
-
79
- h3. Copyright (c) 2008 Matt Hooks. See LICENSE for details.
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :patch: 2
3
- :major: 0
4
- :minor: 1
data/lib/vimeo.rb DELETED
@@ -1,883 +0,0 @@
1
- require 'rubygems'
2
- require 'httparty'
3
- require 'digest/md5'
4
- require 'cgi'
5
-
6
- class VimeoSimple
7
- include HTTParty
8
- base_uri 'vimeo.com/api'
9
-
10
- # USER
11
- def self.user_info(username)
12
- get("/#{username}/info.json")
13
- end
14
-
15
- def self.user_clips(username)
16
- get("/#{username}/clips.json")
17
- end
18
-
19
- def self.user_likes(username)
20
- get("/#{username}/likes.json")
21
- end
22
-
23
- def self.user_appears_in(username)
24
- get("/#{username}/appears_in.json")
25
- end
26
-
27
- def self.user_all_clips(username)
28
- get("/#{username}/all_clips.json")
29
- end
30
-
31
- def self.user_subscriptions(username)
32
- get("/#{username}/subscriptions.json")
33
- end
34
-
35
- def self.user_albums(username)
36
- get("/#{username}/albums.json")
37
- end
38
-
39
- def self.user_channels(username)
40
- get("/#{username}/channels.json")
41
- end
42
-
43
- def self.user_groups(username)
44
- get("/#{username}/groups.json")
45
- end
46
-
47
- def self.user_contacts_clips(username)
48
- get("/#{username}/contacts_clips.json")
49
- end
50
-
51
- def self.user_contacts_like(username)
52
- get("/#{username}/contacts_like.json")
53
- end
54
-
55
- # CLIPS
56
- def self.clip_info(video_id)
57
- get("/clip/#{video_id}.json")
58
- end
59
-
60
- # ACTIVITY
61
- def self.activity_user_did(username)
62
- get("/activity/#{username}/user_did.json")
63
- end
64
-
65
- def self.activity_happened_to_user(username)
66
- get("/activity/#{username}/happened_to_user.json")
67
- end
68
-
69
- def self.activity_contacts_did(username)
70
- get("/activity/#{username}/contacts_did.json")
71
- end
72
-
73
- def self.activity_happened_to_contacts(username)
74
- get("/activity/#{username}/happened_to_contacts.json")
75
- end
76
-
77
- def self.activity_everyone_did(username)
78
- get("/activity/#{username}/everyone_did.json")
79
- end
80
-
81
- # GROUPS
82
- def self.group_clips(groupname)
83
- get("/group/#{groupname}/clips.json")
84
- end
85
-
86
- def self.group_users(groupname)
87
- get("/group/#{groupname}/users.json")
88
- end
89
-
90
- def self.group_info(groupname)
91
- get("/group/#{groupname}/info.json")
92
- end
93
-
94
- # CHANNELS
95
- def self.channel_clips(channelname)
96
- get("/channel/#{channelname}/clips.json")
97
- end
98
-
99
- def self.channel_info(channelname)
100
- get("/channel/#{channelname}/info.json")
101
- end
102
-
103
- # ALBUMS
104
- def self.album_clips(album_id)
105
- get("/album/#{album_id}/clips.json")
106
- end
107
-
108
- def self.album_info(album_id)
109
- get("/album/#{album_id}/info.json")
110
- end
111
-
112
- end
113
-
114
- class VimeoAdvanced
115
- include HTTParty
116
- base_uri 'vimeo.com'
117
-
118
- def initialize(api_key, secret, format_options={})
119
- @auth = { :api_key => api_key }
120
- @secret = secret
121
- # TODO: implement format_options
122
- end
123
-
124
- # HELPERS
125
- def login_link(perms)
126
- api_sig = generate_api_sig :perms => perms
127
- "http://vimeo.com/services/auth/?api_key=#{@auth[:api_key]}&perms=#{perms}&api_sig=#{api_sig}"
128
- end
129
-
130
- # TODO: Implement a function that returns the correct upload URL
131
-
132
- def upload_sig(ticket_id, auth_token)
133
- sig_options = {
134
- :ticket_id => ticket_id,
135
- :auth_token => auth_token
136
- }
137
-
138
- generate_api_sig sig_options
139
- end
140
-
141
- # TEST METHODS
142
- def test_echo(options={})
143
- method = "vimeo.test.echo"
144
- options.merge!(:method => method)
145
- api_sig = generate_api_sig options
146
- options.merge!(:api_sig => api_sig)
147
- self.class.post("/api/rest", :query => options)
148
- end
149
-
150
- def test_null(auth_token)
151
- method = "vimeo.test.null"
152
- api_sig = generate_api_sig :auth_token => auth_token, :method => method
153
- self.class.post("/api/rest", :query => {
154
- :api_key => @auth[:api_key],
155
- :method => method,
156
- :auth_token => auth_token,
157
- :api_sig => api_sig
158
- })
159
- end
160
-
161
- def test_login(auth_token)
162
- method = "vimeo.test.login"
163
- api_sig = generate_api_sig :auth_token => auth_token, :method => method
164
- self.class.post("/api/rest", :query => {
165
- :api_key => @auth[:api_key],
166
- :auth_token => auth_token,
167
- :method => method,
168
- :api_sig => api_sig
169
- })
170
- end
171
-
172
- # AUTHENTICATION
173
- def get_token(frob)
174
- method = "vimeo.auth.getToken"
175
- api_sig = generate_api_sig :frob => frob, :method => method
176
- self.class.post("/api/rest", :query => {
177
- :api_key => @auth[:api_key],
178
- :frob => frob,
179
- :method => method,
180
- :api_sig => api_sig
181
- })
182
- end
183
-
184
- def get_frob
185
- method = "vimeo.auth.getFrob"
186
- api_sig = generate_api_sig :method => method
187
- self.class.post("/api/rest", :query => {
188
- :api_key => @auth[:api_key],
189
- :method => method,
190
- :api_sig => api_sig
191
- })
192
- end
193
-
194
- def check_token(auth_token)
195
- method = "vimeo.auth.checkToken"
196
- api_sig = generate_api_sig :auth_token => auth_token, :method => method
197
- self.class.post("/api/rest", :query => {
198
- :api_key => @auth[:api_key],
199
- :auth_token => auth_token,
200
- :method => method,
201
- :api_sig => api_sig
202
- })
203
- end
204
-
205
- # LISTS OF VIDEOS
206
- def videos_get_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0 })
207
- page = options[:page]
208
- per_page = options[:per_page]
209
- full_response = options[:full_response]
210
- method = "vimeo.videos.getList"
211
- api_sig = generate_api_sig :user_id => user_id, :page => page, :per_page => per_page, :fullResponse => full_response, :method => method
212
- self.class.post("/api/rest", :query => {
213
- :api_key => @auth[:api_key],
214
- :user_id => user_id,
215
- :page => page,
216
- :per_page => per_page,
217
- :fullResponse => full_response,
218
- :method => method,
219
- :api_sig => api_sig
220
- })
221
- end
222
-
223
- def videos_get_uploaded_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
224
- page = options[:page]
225
- per_page = options[:per_page]
226
- full_response = options[:full_response]
227
- auth_token = options[:auth_token]
228
- method = "vimeo.videos.getUploadedList"
229
- api_sig = generate_api_sig :user_id => user_id, :page => page, :per_page => per_page, :fullResponse => full_response, :auth_token => auth_token, :method => method
230
- self.class.post("/api/rest", :query => {
231
- :api_key => @auth[:api_key],
232
- :user_id => user_id,
233
- :page => page,
234
- :per_page => per_page,
235
- :fullResponse => full_response,
236
- :auth_token => auth_token,
237
- :method => method,
238
- :api_sig => api_sig
239
- })
240
- end
241
-
242
- def videos_get_appears_in_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
243
- page = options[:page]
244
- per_page = options[:per_page]
245
- full_response = options[:full_response]
246
- auth_token = options[:auth_token]
247
- method = "vimeo.videos.getAppearsInList"
248
- api_sig = generate_api_sig :user_id => user_id, :page => page, :per_page => per_page, :fullResponse => full_response, :auth_token => auth_token, :method => method
249
- self.class.post("/api/rest", :query => {
250
- :api_key => @auth[:api_key],
251
- :user_id => user_id,
252
- :page => page,
253
- :per_page => per_page,
254
- :fullResponse => full_response,
255
- :auth_token => auth_token,
256
- :method => method,
257
- :api_sig => api_sig
258
- })
259
- end
260
-
261
- def videos_get_subscriptions_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
262
- page = options[:page]
263
- per_page = options[:per_page]
264
- full_response = options[:full_response]
265
- auth_token = options[:auth_token]
266
- method = "vimeo.videos.getSubscriptionsList"
267
- api_sig = generate_api_sig :user_id => user_id, :page => page, :per_page => per_page, :fullResponse => full_response, :auth_token => auth_token, :method => method
268
- self.class.post("/api/rest", :query => {
269
- :api_key => @auth[:api_key],
270
- :user_id => user_id,
271
- :page => page,
272
- :per_page => per_page,
273
- :fullResponse => full_response,
274
- :auth_token => auth_token,
275
- :method => method,
276
- :api_sig => api_sig
277
- })
278
- end
279
-
280
- def videos_get_list_by_tag(tag, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
281
- user_id = options[:user_id]
282
- page = options[:page]
283
- per_page = options[:per_page]
284
- full_response = options[:full_response]
285
- auth_token = options[:auth_token]
286
- method = "vimeo.videos.getListByTag"
287
-
288
- sig_options = {
289
- :tag => tag,
290
- :page => page,
291
- :per_page => per_page,
292
- :fullResponse => full_response,
293
- :auth_token => auth_token,
294
- :method => method
295
- }
296
- sig_options.merge! :user_id => user_id if !user_id.nil?
297
-
298
- api_sig = generate_api_sig sig_options
299
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
300
-
301
- self.class.post("/api/rest", :query => query)
302
- end
303
-
304
- def videos_get_like_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
305
- page = options[:page]
306
- per_page = options[:per_page]
307
- full_response = options[:full_response]
308
- auth_token = options[:auth_token]
309
- method = "vimeo.videos.getLikeList"
310
-
311
- sig_options = {
312
- :user_id => user_id,
313
- :page => page,
314
- :per_page => per_page,
315
- :fullResponse => full_response,
316
- :auth_token => auth_token,
317
- :method => method
318
- }
319
-
320
- api_sig = generate_api_sig sig_options
321
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
322
-
323
- self.class.post("/api/rest", :query => query)
324
- end
325
-
326
- def videos_get_contacts_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
327
- page = options[:page]
328
- per_page = options[:per_page]
329
- full_response = options[:full_response]
330
- auth_token = options[:auth_token]
331
- method = "vimeo.videos.getContactsList"
332
-
333
- sig_options = {
334
- :user_id => user_id,
335
- :page => page,
336
- :per_page => per_page,
337
- :fullResponse => full_response,
338
- :auth_token => auth_token,
339
- :method => method
340
- }
341
-
342
- api_sig = generate_api_sig sig_options
343
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
344
-
345
- self.class.post("/api/rest", :query => query)
346
- end
347
-
348
- def videos_get_contacts_like_list(user_id, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
349
- page = options[:page]
350
- per_page = options[:per_page]
351
- full_response = options[:full_response]
352
- auth_token = options[:auth_token]
353
- method = "vimeo.videos.getContactsLikeList"
354
-
355
- sig_options = {
356
- :user_id => user_id,
357
- :page => page,
358
- :per_page => per_page,
359
- :fullResponse => full_response,
360
- :auth_token => auth_token,
361
- :method => method
362
- }
363
-
364
- api_sig = generate_api_sig sig_options
365
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
366
-
367
- self.class.post("/api/rest", :query => query)
368
- end
369
-
370
- def videos_search(q, options={ :page => 1, :per_page => 25, :full_response => 0, :auth_token => nil })
371
- user_id = options[:user_id]
372
- contacts_only = options[:contacts_only]
373
- page = options[:page]
374
- per_page = options[:per_page]
375
- full_response = options[:full_response]
376
- auth_token = options[:auth_token]
377
- method = "vimeo.videos.search"
378
- escaped_query = CGI.escape(q)
379
-
380
- sig_options = {
381
- :query => escaped_query,
382
- :page => page,
383
- :per_page => per_page,
384
- :fullResponse => full_response,
385
- :auth_token => auth_token,
386
- :method => method
387
- }
388
- sig_options.merge! :user_id => user_id if !user_id.nil?
389
- sig_options.merge! :contacts_only => contacts_only if !contacts_only.nil?
390
-
391
- api_sig = generate_api_sig sig_options
392
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
393
-
394
- self.class.post("/api/rest", :query => query)
395
- end
396
-
397
- # DEALING WITH SPECIFIC VIDEOS
398
- def video_get_info(video_id, auth_token=nil)
399
- method = "vimeo.videos.getInfo"
400
-
401
- sig_options = {
402
- :video_id => video_id,
403
- :auth_token => auth_token,
404
- :method => method
405
- }
406
-
407
- api_sig = generate_api_sig sig_options
408
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
409
-
410
- self.class.post("/api/rest", :query => query)
411
- end
412
-
413
- def video_delete(video_id, auth_token)
414
- method = "vimeo.videos.delete"
415
-
416
- sig_options = {
417
- :video_id => video_id,
418
- :auth_token => auth_token,
419
- :method => method
420
- }
421
-
422
- api_sig = generate_api_sig sig_options
423
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
424
-
425
- self.class.post("/api/rest", :query => query)
426
- end
427
-
428
- def video_get_thumbnail_url(video_id, size=100)
429
- method = "vimeo.videos.getThumbnailUrl"
430
-
431
- sig_options = {
432
- :video_id => video_id,
433
- :size => size,
434
- :method => method
435
- }
436
-
437
- api_sig = generate_api_sig sig_options
438
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
439
-
440
- self.class.post("/api/rest", :query => query)
441
- end
442
-
443
- def video_set_title(video_id, title, auth_token)
444
- method = "vimeo.videos.setTitle"
445
- escaped_title = CGI.escape(title)
446
-
447
- sig_options = {
448
- :video_id => video_id,
449
- :title => escaped_title,
450
- :auth_token => auth_token,
451
- :method => method
452
- }
453
-
454
- api_sig = generate_api_sig sig_options
455
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
456
-
457
- self.class.post("/api/rest", :query => query)
458
- end
459
-
460
- def video_set_caption(video_id, caption, auth_token)
461
- method = "vimeo.videos.setCaption"
462
- escaped_caption = CGI.escape(caption)
463
-
464
- sig_options = {
465
- :video_id => video_id,
466
- :caption => escaped_caption,
467
- :auth_token => auth_token,
468
- :method => method
469
- }
470
-
471
- api_sig = generate_api_sig sig_options
472
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
473
-
474
- self.class.post("/api/rest", :query => query)
475
- end
476
-
477
- def video_set_favorite(video_id, favorite, auth_token)
478
- method = "vimeo.videos.setFavorite"
479
- f = favorite ? true : false
480
-
481
- sig_options = {
482
- :video_id => video_id,
483
- :favorite => f,
484
- :auth_token => auth_token,
485
- :method => method
486
- }
487
-
488
- api_sig = generate_api_sig sig_options
489
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
490
-
491
- self.class.post("/api/rest", :query => query)
492
- end
493
-
494
- def video_add_tags(video_id, tags, auth_token)
495
- method = "vimeo.videos.addTags"
496
-
497
- sig_options = {
498
- :video_id => video_id,
499
- :tags => tags,
500
- :auth_token => auth_token,
501
- :method => method
502
- }
503
-
504
- api_sig = generate_api_sig sig_options
505
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
506
-
507
- self.class.post("/api/rest", :query => query)
508
- end
509
-
510
- def video_remove_tag(video_id, tag_id, auth_token)
511
- method = "vimeo.videos.removeTag"
512
-
513
- sig_options = {
514
- :video_id => video_id,
515
- :tag_id => tag_id,
516
- :auth_token => auth_token,
517
- :method => method
518
- }
519
-
520
- api_sig = generate_api_sig sig_options
521
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
522
-
523
- self.class.post("/api/rest", :query => query)
524
- end
525
-
526
- def video_clear_tags(video_id, auth_token)
527
- method = "vimeo.videos.clearTags"
528
-
529
- sig_options = {
530
- :video_id => video_id,
531
- :auth_token => auth_token,
532
- :method => method
533
- }
534
-
535
- api_sig = generate_api_sig sig_options
536
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
537
-
538
- self.class.post("/api/rest", :query => query)
539
- end
540
-
541
- def video_add_cast(video_id, user_id, auth_token, options={})
542
- method = "vimeo.videos.addCast"
543
-
544
- sig_options = {
545
- :video_id => video_id,
546
- :user_id => user_id,
547
- :auth_token => auth_token,
548
- :method => method
549
- }
550
- sig_options.merge! :role => options[:role] unless options[:role].nil?
551
-
552
- api_sig = generate_api_sig sig_options
553
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
554
-
555
- self.class.post("/api/rest", :query => query)
556
- end
557
-
558
- def video_get_cast(video_id, auth_token=nil)
559
- method = "vimeo.videos.getCast"
560
-
561
- sig_options = {
562
- :video_id => video_id,
563
- :auth_token => auth_token,
564
- :method => method
565
- }
566
-
567
- api_sig = generate_api_sig sig_options
568
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
569
-
570
- self.class.post("/api/rest", :query => query)
571
- end
572
-
573
- def video_remove_cast(video_id, user_id, auth_token)
574
- method = "vimeo.videos.removeCast"
575
-
576
- sig_options = {
577
- :video_id => video_id,
578
- :user_id => user_id,
579
- :auth_token => auth_token,
580
- :method => method
581
- }
582
-
583
- api_sig = generate_api_sig sig_options
584
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
585
-
586
- self.class.post("/api/rest", :query => query)
587
- end
588
-
589
- # TODO: Add ability to specify users
590
- def video_set_privacy(video_id, privacy, auth_token)
591
- method = "vimeo.videos.setPrivacy"
592
-
593
- sig_options = {
594
- :video_id => video_id,
595
- :privacy => privacy,
596
- :auth_token => auth_token,
597
- :method => method
598
- }
599
-
600
- api_sig = generate_api_sig sig_options
601
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
602
-
603
- self.class.post("/api/rest", :query => query)
604
- end
605
-
606
- # VIDEO COMMENTS
607
- def video_get_comments_list(video_id)
608
- method = "vimeo.videos.comments.getList"
609
-
610
- sig_options = {
611
- :video_id => video_id,
612
- :method => method
613
- }
614
-
615
- api_sig = generate_api_sig sig_options
616
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
617
-
618
- self.class.post("/api/rest", :query => query)
619
- end
620
-
621
- def video_add_comment(video_id, comment_text, auth_token, options={})
622
- reply_to_comment_id = options[:reply_to_comment_id]
623
- method = "vimeo.videos.comments.addComment"
624
-
625
- sig_options = {
626
- :video_id => video_id,
627
- :comment_text => comment_text,
628
- :auth_token => auth_token,
629
- :method => method
630
- }
631
- sig_options.merge! :reply_to_comment_id => reply_to_comment_id unless reply_to_comment_id.nil?
632
-
633
- api_sig = generate_api_sig sig_options
634
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
635
-
636
- self.class.post("/api/rest", :query => query)
637
- end
638
-
639
- def video_delete_comment(video_id, comment_id, auth_token)
640
- method = "vimeo.videos.comments.deleteComment"
641
-
642
- sig_options = {
643
- :video_id => video_id,
644
- :comment_id => comment_id,
645
- :auth_token => auth_token,
646
- :method => method
647
- }
648
-
649
- api_sig = generate_api_sig sig_options
650
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
651
-
652
- self.class.post("/api/rest", :query => query)
653
- end
654
-
655
- def video_edit_comment(video_id, comment_id, comment_text, auth_token)
656
- method = "vimeo.videos.comments.editComment"
657
-
658
- sig_options = {
659
- :video_id => video_id,
660
- :comment_id => comment_id,
661
- :comment_text => comment_text,
662
- :auth_token => auth_token,
663
- :method => method
664
- }
665
-
666
- api_sig = generate_api_sig sig_options
667
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
668
-
669
- self.class.post("/api/rest", :query => query)
670
- end
671
-
672
- # PEOPLE (USERS)
673
- def people_find_by_user_name(username)
674
- method = "vimeo.people.findByUserName"
675
-
676
- sig_options = {
677
- :username => username,
678
- :method => method
679
- }
680
-
681
- api_sig = generate_api_sig sig_options
682
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
683
-
684
- self.class.post("/api/rest", :query => query)
685
- end
686
-
687
- def people_find_by_email(find_email)
688
- method = "vimeo.people.findByEmail"
689
-
690
- sig_options = {
691
- :find_email => find_email,
692
- :method => method
693
- }
694
-
695
- api_sig = generate_api_sig sig_options
696
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
697
-
698
- self.class.post("/api/rest", :query => query)
699
- end
700
-
701
- def people_get_info(user_id)
702
- method = "vimeo.people.getInfo"
703
-
704
- sig_options = {
705
- :user_id => user_id,
706
- :method => method
707
- }
708
-
709
- api_sig = generate_api_sig sig_options
710
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
711
-
712
- self.class.post("/api/rest", :query => query)
713
- end
714
-
715
- # TODO: This seems to be returning nil from Vimeo... not implemented?
716
- def people_get_portrait_url(user_id, options={})
717
- size = options[:size]
718
- method = "vimeo.people.getPortraitUrl"
719
-
720
- sig_options = {
721
- :user_id => user_id,
722
- :method => method
723
- }
724
- sig_options.merge! :size => size unless size.nil?
725
-
726
- api_sig = generate_api_sig sig_options
727
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
728
-
729
- self.class.post("/api/rest", :query => query)
730
- end
731
-
732
- # TODO: Not working on Vimeo's side
733
- def people_add_contact(user_id, auth_token)
734
- method = "vimeo.people.addContact"
735
-
736
- sig_options = {
737
- :user_id => user_id,
738
- :auth_token => auth_token,
739
- :method => method
740
- }
741
-
742
- api_sig = generate_api_sig sig_options
743
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
744
-
745
- self.class.post("/api/rest", :query => query)
746
- end
747
-
748
- # TODO: Not working on Vimeo's side
749
- def people_remove_contact(user_id, auth_token)
750
- method = "vimeo.people.removeContact"
751
-
752
- sig_options = {
753
- :user_id => user_id,
754
- :auth_token => auth_token,
755
- :method => method
756
- }
757
-
758
- api_sig = generate_api_sig sig_options
759
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
760
-
761
- self.class.post("/api/rest", :query => query)
762
- end
763
-
764
- def people_get_upload_status(user_id, auth_token)
765
- method = "vimeo.people.getUploadStatus"
766
-
767
- sig_options = {
768
- :user_id => user_id,
769
- :auth_token => auth_token,
770
- :method => method
771
- }
772
-
773
- api_sig = generate_api_sig sig_options
774
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
775
-
776
- self.class.post("/api/rest", :query => query)
777
- end
778
-
779
- # TODO: Verify input for type?
780
- def people_add_subscription(user_id, type, auth_token)
781
- method = "vimeo.people.addSubscription"
782
-
783
- sig_options = {
784
- :user_id => user_id,
785
- :type => type,
786
- :auth_token => auth_token,
787
- :method => method
788
- }
789
-
790
- api_sig = generate_api_sig sig_options
791
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
792
-
793
- self.class.post("/api/rest", :query => query)
794
- end
795
-
796
- # TODO: Verify input for type?
797
- def people_remove_subscription(user_id, type, auth_token)
798
- method = "vimeo.people.removeSubscription"
799
-
800
- sig_options = {
801
- :user_id => user_id,
802
- :type => type,
803
- :auth_token => auth_token,
804
- :method => method
805
- }
806
-
807
- api_sig = generate_api_sig sig_options
808
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
809
-
810
- self.class.post("/api/rest", :query => query)
811
- end
812
-
813
- # CONTACTS
814
- def contacts_get_list(user_id)
815
- method = "vimeo.contacts.getList"
816
-
817
- sig_options = {
818
- :user_id => user_id,
819
- :method => method
820
- }
821
-
822
- api_sig = generate_api_sig sig_options
823
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
824
-
825
- self.class.post("/api/rest", :query => query)
826
- end
827
-
828
- # GROUPS
829
- # TODO: Only takes group_id as int, not group name
830
- def groups_get_members(group_id)
831
- method = "vimeo.groups.getMembers"
832
-
833
- sig_options = {
834
- :group_id => group_id,
835
- :method => method
836
- }
837
-
838
- api_sig = generate_api_sig sig_options
839
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
840
-
841
- self.class.post("/api/rest", :query => query)
842
- end
843
-
844
- # UPLOAD
845
- def video_get_upload_ticket(auth_token)
846
- method = "vimeo.videos.getUploadTicket"
847
-
848
- sig_options = {
849
- :auth_token => auth_token,
850
- :method => method
851
- }
852
-
853
- api_sig = generate_api_sig sig_options
854
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
855
-
856
- self.class.post("/api/rest", :query => query)
857
- end
858
-
859
- def video_check_upload_status(ticket_id, auth_token)
860
- method = "vimeo.videos.checkUploadStatus"
861
-
862
- sig_options = {
863
- :ticket_id => ticket_id,
864
- :auth_token => auth_token,
865
- :method => method
866
- }
867
-
868
- api_sig = generate_api_sig sig_options
869
- query = sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
870
-
871
- self.class.post("/api/rest", :query => query)
872
- end
873
-
874
- private
875
-
876
- # Keys must be sorted alphabetically
877
- def generate_api_sig(options={})
878
- options.merge! @auth
879
- api_sig = options.sort { |a, b| a.to_s <=> b.to_s }.join
880
- Digest::MD5.hexdigest("#{@secret}#{api_sig}")
881
- end
882
-
883
- end
data/test/test_helper.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'mocha'
5
-
6
- class Test::Unit::TestCase
7
- end
data/test/vimeo_test.rb DELETED
@@ -1,7 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper'
2
-
3
- class VimeoTest < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end