slainer68-vimeo 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,14 @@
1
+ == 0.2.1, released 2009-01-06
2
+
3
+ * Last version was missing files.
4
+
5
+ == 0.2.0, released 2009-01-06
6
+
7
+ * Major re-factor of each request method.
8
+ * Separated the simple and advanced APIs into their own modules.
9
+ * Added some documentation.
10
+ * Updated the README.
11
+
12
+ == 0.1.2, released 2008-10-26
13
+
14
+ * 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.
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :patch: 1
3
+ :major: 0
4
+ :minor: 2
@@ -0,0 +1,36 @@
1
+ module Vimeo
2
+ module Advanced
3
+
4
+ class Auth < Vimeo::Advanced::Base
5
+ # Obtains an authorization token.
6
+ def get_token(frob)
7
+ sig_options = {
8
+ :frob => frob,
9
+ :method => "vimeo.auth.getToken"
10
+ }
11
+
12
+ make_request sig_options
13
+ end
14
+
15
+ # Obtains a frob.
16
+ # Used for desktop based authentication.
17
+ def get_frob
18
+ sig_options = { :method => "vimeo.auth.getFrob" }
19
+
20
+ make_request sig_options
21
+ end
22
+
23
+ # Tests the validity of an authorization token.
24
+ def check_token(auth_token)
25
+ sig_options = {
26
+ :auth_token => auth_token,
27
+ :method => "vimeo.auth.checkToken"
28
+ }
29
+
30
+ make_request sig_options
31
+ end
32
+
33
+ end
34
+
35
+ end # Advanced
36
+ end # Vimeo
@@ -0,0 +1,59 @@
1
+ module Vimeo
2
+ module Advanced
3
+
4
+ class Base
5
+ include HTTParty
6
+ base_uri 'vimeo.com'
7
+
8
+ # TODO: Pass an auth token, if you've already got one
9
+ # TODO: implement format_options
10
+ # Requires your API key and secret phrase.
11
+ # The API key and secret are prepended to every request.
12
+ def initialize(api_key, secret, format_options={})
13
+ @auth = { :api_key => api_key }
14
+ @secret = secret
15
+ end
16
+
17
+ # Generates a link that allows a user to authorize
18
+ # your web application to use the advanced API
19
+ def login_link(perms)
20
+ api_sig = generate_api_sig :perms => perms
21
+ "http://vimeo.com/services/auth/?api_key=#{@auth[:api_key]}&perms=#{perms}&api_sig=#{api_sig}"
22
+ end
23
+
24
+ # TODO: Implement a function that returns the correct upload URL
25
+
26
+ # Generates the proper API signature for a file upload.
27
+ def upload_sig(ticket_id, auth_token)
28
+ sig_options = {
29
+ :ticket_id => ticket_id,
30
+ :auth_token => auth_token
31
+ }
32
+
33
+ generate_api_sig sig_options
34
+ end
35
+
36
+ private
37
+
38
+ # Generates a MD5 hashed API signature for Advanced API requests
39
+ def generate_api_sig(options={})
40
+ # Every request requires the api_key parameter
41
+ options.merge! @auth
42
+ # Keys must be sorted alphabetically
43
+ api_sig = options.sort { |a, b| a.to_s <=> b.to_s }.join
44
+ Digest::MD5.hexdigest("#{@secret}#{api_sig}")
45
+ end
46
+
47
+ def query(sig_options, api_sig)
48
+ sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
49
+ end
50
+
51
+ def make_request(sig_options)
52
+ api_sig = generate_api_sig sig_options
53
+ self.class.post "/api/rest", :query => query(sig_options, api_sig)
54
+ end
55
+
56
+ end # Base
57
+
58
+ end # Advanced
59
+ end # Vimeo
@@ -0,0 +1,18 @@
1
+ module Vimeo
2
+ module Advanced
3
+
4
+ class Contact < Vimeo::Advanced::Base
5
+
6
+ def get_list(user_id)
7
+ sig_options = {
8
+ :user_id => user_id,
9
+ :method => "vimeo.contacts.getList"
10
+ }
11
+
12
+ make_request sig_options
13
+ end
14
+
15
+ end
16
+
17
+ end # Advanced
18
+ end # Vimeo
@@ -0,0 +1,19 @@
1
+ module Vimeo
2
+ module Advanced
3
+
4
+ class Group < Vimeo::Advanced::Base
5
+
6
+ # Fixme: Only takes group_id as int, not group name
7
+ def get_members(group_id)
8
+ sig_options = {
9
+ :group_id => group_id,
10
+ :method => "vimeo.groups.getMembers"
11
+ }
12
+
13
+ make_request sig_options
14
+ end
15
+
16
+ end
17
+
18
+ end # Advanced
19
+ end # Vimeo
@@ -0,0 +1,105 @@
1
+ module Vimeo
2
+ module Advanced
3
+
4
+ class Person < Vimeo::Advanced::Base
5
+
6
+ def find_by_user_name(username)
7
+ sig_options = {
8
+ :username => username,
9
+ :method => "vimeo.people.findByUserName"
10
+ }
11
+
12
+ make_request sig_options
13
+ end
14
+
15
+ def find_by_email(find_email)
16
+ sig_options = {
17
+ :find_email => find_email,
18
+ :method => "vimeo.people.findByEmail"
19
+ }
20
+
21
+ make_request sig_options
22
+ end
23
+
24
+ def get_info(user_id)
25
+ sig_options = {
26
+ :user_id => user_id,
27
+ :method => "vimeo.people.getInfo"
28
+ }
29
+
30
+ make_request sig_options
31
+ end
32
+
33
+ # TODO: This seems to be returning nil from Vimeo... not implemented?
34
+ def get_portrait_url(user_id, options={})
35
+ size = options[:size]
36
+
37
+ sig_options = {
38
+ :user_id => user_id,
39
+ :method => "vimeo.people.getPortraitUrl"
40
+ }
41
+ sig_options.merge! :size => size unless size.nil?
42
+
43
+ make_request sig_options
44
+ end
45
+
46
+ # TODO: Not working on Vimeo's side
47
+ def add_contact(user_id, auth_token)
48
+ sig_options = {
49
+ :user_id => user_id,
50
+ :auth_token => auth_token,
51
+ :method => "vimeo.people.addContact"
52
+ }
53
+
54
+ make_request sig_options
55
+ end
56
+
57
+ # TODO: Not working on Vimeo's side
58
+ def remove_contact(user_id, auth_token)
59
+ sig_options = {
60
+ :user_id => user_id,
61
+ :auth_token => auth_token,
62
+ :method => "vimeo.people.removeContact"
63
+ }
64
+
65
+ make_request sig_options
66
+ end
67
+
68
+ def get_upload_status(user_id, auth_token)
69
+ sig_options = {
70
+ :user_id => user_id,
71
+ :auth_token => auth_token,
72
+ :method => "vimeo.people.getUploadStatus"
73
+ }
74
+
75
+ make_request sig_options
76
+ end
77
+
78
+ # TODO: Verify input for type?
79
+ def add_subscription(user_id, type, auth_token)
80
+ sig_options = {
81
+ :user_id => user_id,
82
+ :type => type,
83
+ :auth_token => auth_token,
84
+ :method => "vimeo.people.addSubscription"
85
+ }
86
+
87
+ make_request sig_options
88
+ end
89
+
90
+ # TODO: Verify input for type?
91
+ def remove_subscription(user_id, type, auth_token)
92
+ sig_options = {
93
+ :user_id => user_id,
94
+ :type => type,
95
+ :auth_token => auth_token,
96
+ :method => "vimeo.people.removeSubscription"
97
+ }
98
+
99
+ make_request sig_options
100
+ end
101
+
102
+ end
103
+
104
+ end # Advanced
105
+ end # Vimeo
@@ -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,36 @@
1
+ module Vimeo
2
+ module Advanced
3
+
4
+ class Upload < Vimeo::Advanced::Base
5
+
6
+ def get_upload_ticket(auth_token)
7
+ sig_options = {
8
+ :auth_token => auth_token,
9
+ :method => "vimeo.videos.getUploadTicket"
10
+ }
11
+
12
+ make_request sig_options
13
+ end
14
+
15
+ def check_upload_status(ticket_id, auth_token)
16
+ sig_options = {
17
+ :ticket_id => ticket_id,
18
+ :auth_token => auth_token,
19
+ :method => "vimeo.videos.checkUploadStatus"
20
+ }
21
+
22
+ make_request sig_options
23
+ end
24
+
25
+ def signature_for_file_upload(ticket_id, auth_token)
26
+ sig_options = {
27
+ :ticket_id => ticket_id,
28
+ :auth_token => auth_token
29
+ }
30
+ generate_api_sig sig_options
31
+ end
32
+
33
+ end
34
+
35
+ end # Advanced
36
+ end # Vimeo
@@ -0,0 +1,327 @@
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
+ escaped_query = CGI.escape(q)
115
+
116
+ sig_options = {
117
+ :query => escaped_query,
118
+ :page => options[:page],
119
+ :per_page => options[:per_page],
120
+ :fullResponse => options[:full_response],
121
+ :auth_token => options[:auth_token],
122
+ :method => "vimeo.videos.search"
123
+ }
124
+ sig_options.merge! :user_id => user_id if !user_id.nil?
125
+ sig_options.merge! :contacts_only => contacts_only if !contacts_only.nil?
126
+
127
+ make_request sig_options
128
+ end
129
+
130
+ def get_info(video_id, auth_token=nil)
131
+ sig_options = {
132
+ :video_id => video_id,
133
+ :auth_token => auth_token,
134
+ :method => "vimeo.videos.getInfo"
135
+ }
136
+
137
+ make_request sig_options
138
+ end
139
+
140
+ def delete(video_id, auth_token)
141
+ sig_options = {
142
+ :video_id => video_id,
143
+ :auth_token => auth_token,
144
+ :method => "vimeo.videos.delete"
145
+ }
146
+
147
+ make_request sig_options
148
+ end
149
+
150
+ def get_thumbnail_url(video_id, size=100)
151
+ sig_options = {
152
+ :video_id => video_id,
153
+ :size => size,
154
+ :method => "vimeo.videos.getThumbnailUrl"
155
+ }
156
+
157
+ make_request sig_options
158
+ end
159
+
160
+ def set_title(video_id, title, auth_token)
161
+ escaped_title = CGI.escape(title)
162
+
163
+ sig_options = {
164
+ :video_id => video_id,
165
+ :title => escaped_title,
166
+ :auth_token => auth_token,
167
+ :method => "vimeo.videos.setTitle"
168
+ }
169
+
170
+ make_request sig_options
171
+ end
172
+
173
+ def set_caption(video_id, caption, auth_token)
174
+ escaped_caption = CGI.escape(caption)
175
+
176
+ sig_options = {
177
+ :video_id => video_id,
178
+ :caption => escaped_caption,
179
+ :auth_token => auth_token,
180
+ :method => "vimeo.videos.setCaption"
181
+ }
182
+
183
+ make_request sig_options
184
+ end
185
+
186
+ def set_favorite(video_id, favorite, auth_token)
187
+ f = favorite ? true : false
188
+
189
+ sig_options = {
190
+ :video_id => video_id,
191
+ :favorite => f,
192
+ :auth_token => auth_token,
193
+ :method => "vimeo.videos.setFavorite"
194
+ }
195
+
196
+ make_request sig_options
197
+ end
198
+
199
+ def add_tags(video_id, tags, auth_token)
200
+ sig_options = {
201
+ :video_id => video_id,
202
+ :tags => tags,
203
+ :auth_token => auth_token,
204
+ :method => "vimeo.videos.addTags"
205
+ }
206
+
207
+ make_request sig_options
208
+ end
209
+
210
+ def remove_tag(video_id, tag_id, auth_token)
211
+ sig_options = {
212
+ :video_id => video_id,
213
+ :tag_id => tag_id,
214
+ :auth_token => auth_token,
215
+ :method => "vimeo.videos.removeTag"
216
+ }
217
+
218
+ make_request sig_options
219
+ end
220
+
221
+ def clear_tags(video_id, auth_token)
222
+ sig_options = {
223
+ :video_id => video_id,
224
+ :auth_token => auth_token,
225
+ :method => "vimeo.videos.clearTags"
226
+ }
227
+
228
+ make_request sig_options
229
+ end
230
+
231
+ def add_cast(video_id, user_id, auth_token, options={})
232
+ role = options[:role]
233
+
234
+ sig_options = {
235
+ :video_id => video_id,
236
+ :user_id => user_id,
237
+ :auth_token => auth_token,
238
+ :method => "vimeo.videos.addCast"
239
+ }
240
+ sig_options.merge! :role => role unless role.nil?
241
+
242
+ make_request sig_options
243
+ end
244
+
245
+ def get_cast(video_id, auth_token=nil)
246
+ sig_options = {
247
+ :video_id => video_id,
248
+ :auth_token => auth_token,
249
+ :method => "vimeo.videos.getCast"
250
+ }
251
+
252
+ make_request sig_options
253
+ end
254
+
255
+ def remove_cast(video_id, user_id, auth_token)
256
+ sig_options = {
257
+ :video_id => video_id,
258
+ :user_id => user_id,
259
+ :auth_token => auth_token,
260
+ :method => "vimeo.videos.removeCast"
261
+ }
262
+
263
+ make_request sig_options
264
+ end
265
+
266
+ # TODO: Add ability to specify users
267
+ def set_privacy(video_id, privacy, auth_token)
268
+ sig_options = {
269
+ :video_id => video_id,
270
+ :privacy => privacy,
271
+ :auth_token => auth_token,
272
+ :method => "vimeo.videos.setPrivacy"
273
+ }
274
+
275
+ make_request sig_options
276
+ end
277
+
278
+ def get_comments_list(video_id)
279
+ sig_options = {
280
+ :video_id => video_id,
281
+ :method => "vimeo.videos.comments.getList"
282
+ }
283
+
284
+ make_request sig_options
285
+ end
286
+
287
+ def add_comment(video_id, comment_text, auth_token, options={})
288
+ reply_to_comment_id = options[:reply_to_comment_id]
289
+
290
+ sig_options = {
291
+ :video_id => video_id,
292
+ :comment_text => comment_text,
293
+ :auth_token => auth_token,
294
+ :method => "vimeo.videos.comments.addComment"
295
+ }
296
+ sig_options.merge! :reply_to_comment_id => reply_to_comment_id unless reply_to_comment_id.nil?
297
+
298
+ make_request sig_options
299
+ end
300
+
301
+ def delete_comment(video_id, comment_id, auth_token)
302
+ sig_options = {
303
+ :video_id => video_id,
304
+ :comment_id => comment_id,
305
+ :auth_token => auth_token,
306
+ :method => "vimeo.videos.comments.deleteComment"
307
+ }
308
+
309
+ make_request sig_options
310
+ end
311
+
312
+ def edit_comment(video_id, comment_id, comment_text, auth_token)
313
+ sig_options = {
314
+ :video_id => video_id,
315
+ :comment_id => comment_id,
316
+ :comment_text => comment_text,
317
+ :auth_token => auth_token,
318
+ :method => "vimeo.videos.comments.editComment"
319
+ }
320
+
321
+ make_request sig_options
322
+ end
323
+
324
+ end
325
+
326
+ end # Advanced
327
+ end # Vimeo
@@ -0,0 +1,12 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'advanced/base'
3
+ require 'advanced/auth'
4
+ require 'advanced/test'
5
+ require 'advanced/video'
6
+ require 'advanced/upload'
7
+
8
+ module Vimeo
9
+ module Advanced
10
+
11
+ end
12
+ 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,14 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'simple/base'
3
+ require 'simple/activity'
4
+ require 'simple/album'
5
+ require 'simple/channel'
6
+ require 'simple/clip'
7
+ require 'simple/group'
8
+ require 'simple/user'
9
+
10
+ module Vimeo
11
+ module Simple
12
+
13
+ end # Simple
14
+ end # Vimeo
data/lib/vimeo.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'digest/md5'
4
+ require 'cgi'
5
+
6
+ $:.unshift(File.dirname(__FILE__))
7
+ require 'vimeo/simple'
8
+ require 'vimeo/advanced'
9
+
10
+ module Vimeo
11
+
12
+ end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+
6
+ class Test::Unit::TestCase
7
+ end
@@ -0,0 +1,7 @@
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
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slainer68-vimeo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Matt Hooks
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-07 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: jnunemaker-httparty
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.2.6
24
+ version:
25
+ description: A full featured Ruby implementation of the Vimeo API.
26
+ email: matthooks@gmail.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ - LICENSE
34
+ - CHANGELOG.rdoc
35
+ files:
36
+ - CHANGELOG.rdoc
37
+ - README.rdoc
38
+ - VERSION.yml
39
+ - lib/vimeo
40
+ - lib/vimeo/advanced
41
+ - lib/vimeo/advanced/auth.rb
42
+ - lib/vimeo/advanced/base.rb
43
+ - lib/vimeo/advanced/contact.rb
44
+ - lib/vimeo/advanced/group.rb
45
+ - lib/vimeo/advanced/person.rb
46
+ - lib/vimeo/advanced/test.rb
47
+ - lib/vimeo/advanced/upload.rb
48
+ - lib/vimeo/advanced/video.rb
49
+ - lib/vimeo/advanced.rb
50
+ - lib/vimeo/simple
51
+ - lib/vimeo/simple/activity.rb
52
+ - lib/vimeo/simple/album.rb
53
+ - lib/vimeo/simple/base.rb
54
+ - lib/vimeo/simple/channel.rb
55
+ - lib/vimeo/simple/clip.rb
56
+ - lib/vimeo/simple/group.rb
57
+ - lib/vimeo/simple/user.rb
58
+ - lib/vimeo/simple.rb
59
+ - lib/vimeo.rb
60
+ - test/test_helper.rb
61
+ - test/vimeo_test.rb
62
+ - LICENSE
63
+ has_rdoc: true
64
+ homepage: http://github.com/slainer68/vimeo
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --main
68
+ - README.rdoc
69
+ - --inline-source
70
+ - --charset=UTF-8
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project:
88
+ rubygems_version: 1.2.0
89
+ signing_key:
90
+ specification_version: 2
91
+ summary: A full featured Ruby implementation of the Vimeo API.
92
+ test_files: []
93
+