vimeo 1.0.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.
- data/.gitignore +3 -0
- data/CHANGELOG.rdoc +24 -0
- data/LICENSE +20 -0
- data/README.rdoc +322 -0
- data/Rakefile +68 -0
- data/VERSION.yml +4 -0
- data/lib/vimeo/advanced/album.rb +57 -0
- data/lib/vimeo/advanced/auth.rb +22 -0
- data/lib/vimeo/advanced/base.rb +105 -0
- data/lib/vimeo/advanced/channel.rb +58 -0
- data/lib/vimeo/advanced/contact.rb +31 -0
- data/lib/vimeo/advanced/group.rb +68 -0
- data/lib/vimeo/advanced/group_events.rb +25 -0
- data/lib/vimeo/advanced/group_forums.rb +19 -0
- data/lib/vimeo/advanced/person.rb +48 -0
- data/lib/vimeo/advanced/test.rb +36 -0
- data/lib/vimeo/advanced/upload.rb +62 -0
- data/lib/vimeo/advanced/video.rb +131 -0
- data/lib/vimeo/advanced/video_embed.rb +19 -0
- data/lib/vimeo/advanced.rb +20 -0
- data/lib/vimeo/simple/activity.rb +42 -0
- data/lib/vimeo/simple/album.rb +21 -0
- data/lib/vimeo/simple/base.rb +10 -0
- data/lib/vimeo/simple/channel.rb +21 -0
- data/lib/vimeo/simple/group.rb +28 -0
- data/lib/vimeo/simple/user.rb +84 -0
- data/lib/vimeo/simple/video.rb +14 -0
- data/lib/vimeo/simple.rb +14 -0
- data/lib/vimeo.rb +10 -0
- data/test/fixtures/advanced/album/add_video.json +4 -0
- data/test/fixtures/advanced/album/create.json +7 -0
- data/test/fixtures/advanced/album/delete.json +4 -0
- data/test/fixtures/advanced/album/get_all.json +111 -0
- data/test/fixtures/advanced/album/get_videos.json +30 -0
- data/test/fixtures/advanced/album/remove_video.json +4 -0
- data/test/fixtures/advanced/album/set_description.json +4 -0
- data/test/fixtures/advanced/album/set_password.json +4 -0
- data/test/fixtures/advanced/album/set_title.json +4 -0
- data/test/fixtures/advanced/auth/check_token.json +13 -0
- data/test/fixtures/advanced/auth/get_frob.json +5 -0
- data/test/fixtures/advanced/auth/get_token.json +13 -0
- data/test/fixtures/advanced/channel/add_video.json +4 -0
- data/test/fixtures/advanced/channel/get_all.json +1395 -0
- data/test/fixtures/advanced/channel/get_info.json +55 -0
- data/test/fixtures/advanced/channel/get_moderators.json +45 -0
- data/test/fixtures/advanced/channel/get_subscribers.json +44 -0
- data/test/fixtures/advanced/channel/get_videos.json +19 -0
- data/test/fixtures/advanced/channel/remove_video.json +4 -0
- data/test/fixtures/advanced/channel/subscribe.json +4 -0
- data/test/fixtures/advanced/channel/unsubscribe.json +4 -0
- data/test/fixtures/advanced/contact/get_all.json +117 -0
- data/test/fixtures/advanced/contact/get_mutual.json +80 -0
- data/test/fixtures/advanced/contact/get_online.json +47 -0
- data/test/fixtures/advanced/contact/get_who_added.json +117 -0
- data/test/fixtures/advanced/group/add_video.json +4 -0
- data/test/fixtures/advanced/group/get_all.json +1556 -0
- data/test/fixtures/advanced/group/get_files.json +255 -0
- data/test/fixtures/advanced/group/get_info.json +73 -0
- data/test/fixtures/advanced/group/get_members.json +862 -0
- data/test/fixtures/advanced/group/get_moderators.json +44 -0
- data/test/fixtures/advanced/group/get_video_comments.json +96 -0
- data/test/fixtures/advanced/group/get_videos.json +102 -0
- data/test/fixtures/advanced/group/join.json +4 -0
- data/test/fixtures/advanced/group/leave.json +4 -0
- data/test/fixtures/advanced/group_events/get_month.json +146 -0
- data/test/fixtures/advanced/group_events/get_past.json +146 -0
- data/test/fixtures/advanced/group_events/get_upcoming.json +146 -0
- data/test/fixtures/advanced/group_forums/get_topic_comments.json +224 -0
- data/test/fixtures/advanced/group_forums/get_topics.json +504 -0
- data/test/fixtures/advanced/person/add_contact.json +4 -0
- data/test/fixtures/advanced/person/add_subscription.json +4 -0
- data/test/fixtures/advanced/person/find_by_email.json +9 -0
- data/test/fixtures/advanced/person/get_hd_embeds.json +8 -0
- data/test/fixtures/advanced/person/get_info.json +21 -0
- data/test/fixtures/advanced/person/get_portrait_urls.json +28 -0
- data/test/fixtures/advanced/person/remove_contact.json +4 -0
- data/test/fixtures/advanced/person/remove_subscription.json +4 -0
- data/test/fixtures/advanced/test/echo.json +8 -0
- data/test/fixtures/advanced/test/login.json +8 -0
- data/test/fixtures/advanced/test/null.json +4 -0
- data/test/fixtures/advanced/upload/confirm.json +9 -0
- data/test/fixtures/advanced/upload/get_quota.json +16 -0
- data/test/fixtures/advanced/upload/get_ticket.json +8 -0
- data/test/fixtures/advanced/upload/manifest_to_upload.json +6 -0
- data/test/fixtures/advanced/upload/sample_iTunes.mov +0 -0
- data/test/fixtures/advanced/upload/verify_manifest.json +11 -0
- data/test/fixtures/advanced/video/add_cast.json +4 -0
- data/test/fixtures/advanced/video/add_comment.json +7 -0
- data/test/fixtures/advanced/video/add_photos.json +4 -0
- data/test/fixtures/advanced/video/add_tags.json +4 -0
- data/test/fixtures/advanced/video/clear_tags.json +4 -0
- data/test/fixtures/advanced/video/delete.json +4 -0
- data/test/fixtures/advanced/video/delete_comment.json +4 -0
- data/test/fixtures/advanced/video/edit_comment.json +4 -0
- data/test/fixtures/advanced/video/get_all.json +30 -0
- data/test/fixtures/advanced/video/get_appears_in.json +10 -0
- data/test/fixtures/advanced/video/get_by_tag.json +239 -0
- data/test/fixtures/advanced/video/get_cast.json +42 -0
- data/test/fixtures/advanced/video/get_comments_list.json +52 -0
- data/test/fixtures/advanced/video/get_contacts_liked.json +48 -0
- data/test/fixtures/advanced/video/get_contacts_uploaded.json +237 -0
- data/test/fixtures/advanced/video/get_info.json +246 -0
- data/test/fixtures/advanced/video/get_likes.json +32 -0
- data/test/fixtures/advanced/video/get_subscriptions.json +241 -0
- data/test/fixtures/advanced/video/get_thumbnail_urls.json +28 -0
- data/test/fixtures/advanced/video/get_uploaded.json +30 -0
- data/test/fixtures/advanced/video/remove_cast.json +4 -0
- data/test/fixtures/advanced/video/remove_tag.json +4 -0
- data/test/fixtures/advanced/video/search.json +238 -0
- data/test/fixtures/advanced/video/set_description.json +4 -0
- data/test/fixtures/advanced/video/set_like.json +4 -0
- data/test/fixtures/advanced/video/set_privacy.json +4 -0
- data/test/fixtures/advanced/video/set_title.json +4 -0
- data/test/fixtures/advanced/video_embed/get_presets.json +8 -0
- data/test/fixtures/advanced/video_embed/set_preset.json +4 -0
- data/test/fixtures/simple/activity/contacts_did.json +1 -0
- data/test/fixtures/simple/activity/everyone_did.json +1 -0
- data/test/fixtures/simple/activity/happened_to_contacts.json +1 -0
- data/test/fixtures/simple/activity/happened_to_user.json +1 -0
- data/test/fixtures/simple/activity/user_did.json +1 -0
- data/test/fixtures/simple/album/info.json +1 -0
- data/test/fixtures/simple/album/videos.json +1 -0
- data/test/fixtures/simple/channel/info.json +1 -0
- data/test/fixtures/simple/channel/videos.json +1 -0
- data/test/fixtures/simple/group/info.json +1 -0
- data/test/fixtures/simple/group/users.json +1 -0
- data/test/fixtures/simple/group/videos.json +1 -0
- data/test/fixtures/simple/user/albums.json +1 -0
- data/test/fixtures/simple/user/all_videos.json +1 -0
- data/test/fixtures/simple/user/appears_in.json +1 -0
- data/test/fixtures/simple/user/channels.json +1 -0
- data/test/fixtures/simple/user/contacts_like.json +1 -0
- data/test/fixtures/simple/user/contacts_videos.json +1 -0
- data/test/fixtures/simple/user/groups.json +1 -0
- data/test/fixtures/simple/user/info.json +1 -0
- data/test/fixtures/simple/user/likes.json +1 -0
- data/test/fixtures/simple/user/subscriptions.json +1 -0
- data/test/fixtures/simple/user/videos.json +1 -0
- data/test/fixtures/simple/video/info.json +1 -0
- data/test/test_helper.rb +50 -0
- data/test/vimeo/advanced/album_test.rb +88 -0
- data/test/vimeo/advanced/auth_test.rb +37 -0
- data/test/vimeo/advanced/base_test.rb +24 -0
- data/test/vimeo/advanced/channels_test.rb +79 -0
- data/test/vimeo/advanced/contacts_test.rb +40 -0
- data/test/vimeo/advanced/group_events_test.rb +33 -0
- data/test/vimeo/advanced/group_forums_test.rb +26 -0
- data/test/vimeo/advanced/groups_test.rb +82 -0
- data/test/vimeo/advanced/person_test.rb +68 -0
- data/test/vimeo/advanced/test_test.rb +33 -0
- data/test/vimeo/advanced/upload_test.rb +50 -0
- data/test/vimeo/advanced/videos_embed_test.rb +26 -0
- data/test/vimeo/advanced/videos_test.rb +203 -0
- data/test/vimeo/advanced_test.rb +0 -0
- data/test/vimeo/simple/activity_test.rb +60 -0
- data/test/vimeo/simple/album_test.rb +31 -0
- data/test/vimeo/simple/channel_test.rb +31 -0
- data/test/vimeo/simple/group_test.rb +41 -0
- data/test/vimeo/simple/user_test.rb +112 -0
- data/test/vimeo/simple/video_test.rb +22 -0
- data/test/vimeo/simple_test.rb +0 -0
- data/test/vimeo_test.rb +0 -0
- data/vimeo.gemspec +244 -0
- metadata +303 -0
data/.gitignore
ADDED
data/CHANGELOG.rdoc
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
== 1.0.0, released 2009-09-28
|
|
2
|
+
|
|
3
|
+
* Upgraded to v2 of the API.
|
|
4
|
+
* Added some upload helpers.
|
|
5
|
+
* Huge refactor for the Advanced API making it easier to add/modify method calls.
|
|
6
|
+
|
|
7
|
+
== 0.2.2, released 2009-04-21
|
|
8
|
+
|
|
9
|
+
* Removed CGI escapes. Vimeo should be handling them on their end.
|
|
10
|
+
|
|
11
|
+
== 0.2.1, released 2009-01-06
|
|
12
|
+
|
|
13
|
+
* Last version was missing files.
|
|
14
|
+
|
|
15
|
+
== 0.2.0, released 2009-01-06
|
|
16
|
+
|
|
17
|
+
* Major re-factor of each request method.
|
|
18
|
+
* Separated the simple and advanced APIs into their own modules.
|
|
19
|
+
* Added some documentation.
|
|
20
|
+
* Updated the README.
|
|
21
|
+
|
|
22
|
+
== 0.1.2, released 2008-10-26
|
|
23
|
+
|
|
24
|
+
* Initial release
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2009 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,322 @@
|
|
|
1
|
+
= Vimeo API Gem
|
|
2
|
+
|
|
3
|
+
This gem implements a full-featured Ruby interface for the Vimeo API v2.
|
|
4
|
+
|
|
5
|
+
For a more in depth look at the API check out {Vimeo's Simple API Documentation}[http://www.vimeo.com/api/docs/simple-api] or {Vimeo's Advanced API Documentation}[http://www.vimeo.com/api/docs/advanced-api]. I would also recommend checking out the {API Forums}[http://www.vimeo.com/forum:api] if
|
|
6
|
+
things aren't working as they should -- in my experience the Vimeo API has a number of bugs and oddities.
|
|
7
|
+
|
|
8
|
+
== Install
|
|
9
|
+
|
|
10
|
+
If you haven't already, add github's gem server to your sources:
|
|
11
|
+
|
|
12
|
+
gem sources -a http://gems.github.com
|
|
13
|
+
|
|
14
|
+
Then, it's as easy as:
|
|
15
|
+
|
|
16
|
+
sudo gem install matthooks-vimeo
|
|
17
|
+
|
|
18
|
+
Add the gem plugin to your Rails project by adding the following to your @environment.rb@ file:
|
|
19
|
+
|
|
20
|
+
config.gem "matthooks-vimeo", :lib => "vimeo"
|
|
21
|
+
|
|
22
|
+
== Use
|
|
23
|
+
|
|
24
|
+
There are two modules:
|
|
25
|
+
|
|
26
|
+
Vimeo::Simple
|
|
27
|
+
Vimeo::Advanced
|
|
28
|
+
|
|
29
|
+
== Simple API
|
|
30
|
+
|
|
31
|
+
The wrapper for the {Simple API}[http://www.vimeo.com/api/docs/simple-api] consists of several classes. To use the Simple API, just call one of the class methods. For example:
|
|
32
|
+
|
|
33
|
+
user_info = Vimeo::Simple::User.info("matthooks")
|
|
34
|
+
# =>
|
|
35
|
+
# {
|
|
36
|
+
# "id":"888046",
|
|
37
|
+
# "display_name":"Matt Hooks",
|
|
38
|
+
# "created_on":"2008-10-30 14:17:32",
|
|
39
|
+
# "is_staff":"0",
|
|
40
|
+
# "is_plus":"0",
|
|
41
|
+
# "location":"Chicago, IL",
|
|
42
|
+
# "url":"http:\/\/blackholeinthemidwest.com\/",
|
|
43
|
+
# "bio":"",
|
|
44
|
+
# "profile_url":"http:\/\/vimeo.com\/matthooks",
|
|
45
|
+
# "videos_url":"http:\/\/vimeo.com\/matthooks\/videos",
|
|
46
|
+
# "total_videos_uploaded":2,
|
|
47
|
+
# "total_videos_appears_in":0,
|
|
48
|
+
# "total_videos_liked":2,
|
|
49
|
+
# "total_contacts":3,
|
|
50
|
+
# "total_albums":0,
|
|
51
|
+
# "total_channels":1,
|
|
52
|
+
# "portrait_small":"http:\/\/images.vimeo.com\/11\/42\/16\/114216178\/114216178_30.jpg",
|
|
53
|
+
# "portrait_medium":"http:\/\/images.vimeo.com\/11\/42\/16\/114216178\/114216178_75.jpg",
|
|
54
|
+
# "portrait_large":"http:\/\/images.vimeo.com\/11\/42\/16\/114216178\/114216178_100.jpg",
|
|
55
|
+
# "portrait_huge":"http:\/\/images.vimeo.com\/11\/42\/16\/114216178\/114216178_300.jpg"
|
|
56
|
+
# }
|
|
57
|
+
|
|
58
|
+
# That's right! The data returned will be parsed and ready to use.
|
|
59
|
+
|
|
60
|
+
user_info["location"]
|
|
61
|
+
# => "Chicago, IL"
|
|
62
|
+
|
|
63
|
+
=== Vimeo::Simple::Activity
|
|
64
|
+
|
|
65
|
+
Vimeo::Simple::Activity.user_did("username")
|
|
66
|
+
Vimeo::Simple::Activity.happened_to_user("username")
|
|
67
|
+
Vimeo::Simple::Activity.contacts_did("username")
|
|
68
|
+
Vimeo::Simple::Activity.happened_to_contacts("username")
|
|
69
|
+
Vimeo::Simple::Activity.everyone_did("username")
|
|
70
|
+
|
|
71
|
+
=== Vimeo::Simple::Album
|
|
72
|
+
|
|
73
|
+
Vimeo::Simple::Album.videos("album_id")
|
|
74
|
+
Vimeo::Simple::Album.info("album_id")
|
|
75
|
+
|
|
76
|
+
=== Vimeo::Simple::Channel
|
|
77
|
+
|
|
78
|
+
Vimeo::Simple::Channel.videos(channelname)
|
|
79
|
+
Vimeo::Simple::Channel.info(channelname)
|
|
80
|
+
|
|
81
|
+
=== Vimeo::Simple::Group
|
|
82
|
+
|
|
83
|
+
Vimeo::Simple::Group.videos(groupname)
|
|
84
|
+
Vimeo::Simple::Group.users(groupname)
|
|
85
|
+
Vimeo::Simple::Group.info(groupname)
|
|
86
|
+
|
|
87
|
+
=== Vimeo::Simple::User
|
|
88
|
+
|
|
89
|
+
Vimeo::Simple::User.info(username)
|
|
90
|
+
Vimeo::Simple::User.videos(username)
|
|
91
|
+
Vimeo::Simple::User.likes(username)
|
|
92
|
+
Vimeo::Simple::User.appears_in(username)
|
|
93
|
+
Vimeo::Simple::User.all_videos(username)
|
|
94
|
+
Vimeo::Simple::User.subscriptions(username)
|
|
95
|
+
Vimeo::Simple::User.albums(username)
|
|
96
|
+
Vimeo::Simple::User.channels(username)
|
|
97
|
+
Vimeo::Simple::User.groups(username)
|
|
98
|
+
Vimeo::Simple::User.contacts_videos(username)
|
|
99
|
+
Vimeo::Simple::User.contacts_like(username)
|
|
100
|
+
|
|
101
|
+
=== Vimeo::Simple::Video
|
|
102
|
+
|
|
103
|
+
Vimeo::Simple::Video.info(video_id)
|
|
104
|
+
|
|
105
|
+
== Advanced API
|
|
106
|
+
|
|
107
|
+
The classes in Vimeo::Advanced must be instantiated with an your application's api key and secret. For example:
|
|
108
|
+
|
|
109
|
+
vimeo_video = Vimeo::Advanced::Video.new("api_key", "secret")
|
|
110
|
+
|
|
111
|
+
Then you can make method calls on the instance. For example:
|
|
112
|
+
|
|
113
|
+
vimeo_video.get_list("matthooks", :page => 2, :per_page => 50)
|
|
114
|
+
|
|
115
|
+
Some methods have optional variables. You should pass as a hash at the end of a call.
|
|
116
|
+
|
|
117
|
+
Some methods require authentication. Check out the guides for {Web Based authentication}[http://www.vimeo.com/api/docs/web-auth] and {Desktop Based authentication}[http://www.vimeo.com/api/docs/desktop-auth].
|
|
118
|
+
|
|
119
|
+
The wrapper for the Advanced API consists of the following classes and methods:
|
|
120
|
+
|
|
121
|
+
=== Vimeo::Advanced::Album
|
|
122
|
+
|
|
123
|
+
album = Vimeo::Advanced::Album.new("api_key", "secret")
|
|
124
|
+
|
|
125
|
+
album.add_video("auth_token", "album_id", "video_id")
|
|
126
|
+
album.create("auth_token", "title", "video_id", { :description => "description", "videos" => "123,124,125" })
|
|
127
|
+
album.delete("auth_token", "album_id")
|
|
128
|
+
album.get_all("user_id", { :page => "1", :per_page => "25" })
|
|
129
|
+
album.get_videos("auth_token", "user_id", { :page => "1", :per_page => "25", :full_response => "0", :password => nil })
|
|
130
|
+
album.get_videos("auth_token", "album_id", "video_id")
|
|
131
|
+
album.set_description("auth_token", "album_id", "description")
|
|
132
|
+
album.get_password("auth_token", "album_id", "password")
|
|
133
|
+
album.get_title("auth_token", "album_id", "title")
|
|
134
|
+
|
|
135
|
+
=== Vimeo::Advanced::Auth
|
|
136
|
+
|
|
137
|
+
auth = Vimeo::Advanced::Auth.new("api_key", "secret")
|
|
138
|
+
|
|
139
|
+
auth.get_token("frob")
|
|
140
|
+
auth.get_frob
|
|
141
|
+
auth.check_token("auth_token")
|
|
142
|
+
|
|
143
|
+
=== Vimeo::Advanced::Base
|
|
144
|
+
|
|
145
|
+
base = Vimeo::Advanced::Base.new("api_key", "secret")
|
|
146
|
+
|
|
147
|
+
base.web_login_link("permissions")
|
|
148
|
+
base.desktop_login_link("permissions")
|
|
149
|
+
|
|
150
|
+
=== Vimeo::Advanced::Channel
|
|
151
|
+
|
|
152
|
+
channel = Vimeo::Advanced::Channel.new("api_key", "secret")
|
|
153
|
+
|
|
154
|
+
channel.add_video("auth_token", "channel_id", "video_id")
|
|
155
|
+
channel.get_all({ :page => "1", :per_page => "25", :sort => "newest"})
|
|
156
|
+
channel.get_info(channel_id, { :page => "1", :per_page => "25" })
|
|
157
|
+
channel.get_moderators(channel_id, { :page => "1", :per_page => "25" })
|
|
158
|
+
channel.get_subscribers(channel_id, { :page => "1", :per_page => "25" })
|
|
159
|
+
channel.get_videos(channel_id, { :page => "1", :per_page => "25", :full_response => "0" })
|
|
160
|
+
channel.remove_video("auth_token", "channel_id", "video_id")
|
|
161
|
+
channel.subscribe("auth_token", "channel_id")
|
|
162
|
+
channel.unsubscribe("auth_token", "channel_id")
|
|
163
|
+
|
|
164
|
+
=== Vimeo::Advanced::Contact
|
|
165
|
+
|
|
166
|
+
contact = Vimeo::Advanced::Contact.new("api_key", "secret")
|
|
167
|
+
|
|
168
|
+
contact.get_all(user_id, { :page => "1", :per_page => "25", :sort => "newest" })
|
|
169
|
+
contact.get_mutual(user_id, { :page => "1", :per_page => "25", :sort => "newest" })
|
|
170
|
+
contact.get_online({ :page => "1", :per_page => "25", :sort => "newest" })
|
|
171
|
+
contact.get_who_added(user_id, { :page => "1", :per_page => "25", :sort => "newest" })
|
|
172
|
+
|
|
173
|
+
=== Vimeo::Advanced::Group
|
|
174
|
+
|
|
175
|
+
group = Vimeo::Advanced::Group.new("api_key", "secret")
|
|
176
|
+
|
|
177
|
+
group.add_video("auth_token", "group_id", "video_id")
|
|
178
|
+
group.get_all({ :page => "1", :per_page => "25", :sort => "newest" })
|
|
179
|
+
group.get_files("group_id", { :page => "1", :per_page => "25" })
|
|
180
|
+
group.get_info("group_id", { :page => "1", :per_page => "25" })
|
|
181
|
+
group.get_members("group_id", { :page => "1", :per_page => "25", :sort => "newest" })
|
|
182
|
+
group.get_moderators("group_id", { :page => "1", :per_page => "25" })
|
|
183
|
+
group.get_video_comments("group_id", "video_id", { :page => "1", :per_page => "25" })
|
|
184
|
+
group.get_videos("group_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
185
|
+
group.join("auth_token", "group_id")
|
|
186
|
+
group.leave("auth_token", "group_id")
|
|
187
|
+
|
|
188
|
+
=== Vimeo::Advanced::GroupEvents
|
|
189
|
+
|
|
190
|
+
group_events = Vimeo::Advanced::GroupEvents.new("api_key", "secret")
|
|
191
|
+
|
|
192
|
+
group_events.get_month("group_id", { :page => "1", :per_page => "25", :month => nil, :year => nil })
|
|
193
|
+
group_events.get_past("group_id", { :page => "1", :per_page => "25" })
|
|
194
|
+
group_events.get_year("group_id", { :page => "1", :per_page => "25" })
|
|
195
|
+
|
|
196
|
+
=== Vimeo::Advanced::GroupForums
|
|
197
|
+
|
|
198
|
+
group_forums = Vimeo::Advanced::GroupForums.new("api_key", "secret")
|
|
199
|
+
|
|
200
|
+
group_forums.get_topic_comments("group_id", "topic_id", { :page => "1", :per_page => "25" })
|
|
201
|
+
group_forums.get_topics("group_id", { :page => "1", :per_page => "25" })
|
|
202
|
+
|
|
203
|
+
=== Vimeo::Advanced::Person
|
|
204
|
+
|
|
205
|
+
person = Vimeo::Advanced::Person.new("api_key", "secret")
|
|
206
|
+
|
|
207
|
+
person.add_contact("auth_token", "user_id")
|
|
208
|
+
# Types is a comma-delimited string. Valid options: "likes", "appears", "uploads"
|
|
209
|
+
person.add_subscription("auth_token", "user_id", "types")
|
|
210
|
+
person.find_by_email("user_id")
|
|
211
|
+
person.get_hd_embeds("auth_token")
|
|
212
|
+
person.get_info("user_id")
|
|
213
|
+
person.get_portrait_urls("user_id")
|
|
214
|
+
person.remove_contact("auth_token", "user_id")
|
|
215
|
+
# Types is a comma-delimited string. Valid options: "likes", "appears", "uploads"
|
|
216
|
+
person.remove_subscription("auth_token", "user_id", "types")
|
|
217
|
+
|
|
218
|
+
=== Vimeo::Advanced::Test
|
|
219
|
+
|
|
220
|
+
test = Vimeo::Advanced::Test.new("api_key", "secret")
|
|
221
|
+
|
|
222
|
+
test.echo(options={})
|
|
223
|
+
test.null(auth_token)
|
|
224
|
+
test.login(auth_token)
|
|
225
|
+
|
|
226
|
+
=== Vimeo::Advanced::Upload
|
|
227
|
+
|
|
228
|
+
upload = Vimeo::Advanced::Upload.new("api_key", "secret")
|
|
229
|
+
|
|
230
|
+
upload.confirm("auth_token", "ticket_id", "json_manifest")
|
|
231
|
+
upload.get_quota("auth_token")
|
|
232
|
+
upload.get_ticket("auth_token")
|
|
233
|
+
upload.upload("auth_token", "path_to_file", "ticket_id", "end_point")
|
|
234
|
+
upload.verify_manifest("auth_token", "ticket_id", "json_manifest")
|
|
235
|
+
|
|
236
|
+
=== Vimeo::Advanced::Video
|
|
237
|
+
|
|
238
|
+
video = Vimeo::Advanced::Video.new("api_key", "secret")
|
|
239
|
+
|
|
240
|
+
video.add_cast("auth_token", "video_id", "user_id", { :role => nil })
|
|
241
|
+
video.add_photos("auth_token", "video_id", "photo_urls")
|
|
242
|
+
video.add_tags("auth_token", "video_id", "tags")
|
|
243
|
+
video.clear_tags("auth_token", "video_id")
|
|
244
|
+
video.delete("auth_token", "video_id")
|
|
245
|
+
video.get_all("user_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
246
|
+
video.get_appears_in("user_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
247
|
+
video.get_by_tag("tag", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
248
|
+
video.get_cast("video_id", { :page => "1", :per_page => "25" })
|
|
249
|
+
video.get_contacts_liked("user_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
250
|
+
video.get_contacts_uploaded("user_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
251
|
+
video.get_info("video_id")
|
|
252
|
+
video.get_likes("user_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
253
|
+
video.get_subscriptions("user_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
254
|
+
video.get_thumbnail_urls("video_id")
|
|
255
|
+
video.get_uploaded("user_id", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest" })
|
|
256
|
+
video.remove_cast("auth_token", "video_id", "user_id")
|
|
257
|
+
video.remove_tag("auth_token", "video_id", "tag_id")
|
|
258
|
+
video.search("query", { :page => "1", :per_page => "25", :full_response => "0", :sort => "newest", :user_id => nil })
|
|
259
|
+
video.set_description("auth_token", "video_id", "description")
|
|
260
|
+
video.set_like("auth_token", "video_id", "like")
|
|
261
|
+
video.set_privacy("auth_token", "video_id", "privacy", { :users => nil, :password => nil })
|
|
262
|
+
video.set_title("auth_token", "video_id", "title")
|
|
263
|
+
|
|
264
|
+
# comments
|
|
265
|
+
video.add_comment("auth_token", "video_id", "comment_text", { :reply_to_comment_id => nil })
|
|
266
|
+
video.delete_comment("auth_token", "video_id", "comment_id")
|
|
267
|
+
video.edit_comment("auth_token", "video_id", "comment_id", "comment_text")
|
|
268
|
+
video.get_comments_list("video_id", { :page => "1", :per_page => "25" })
|
|
269
|
+
|
|
270
|
+
=== Vimeo::Advanced::VideoEmbed
|
|
271
|
+
|
|
272
|
+
video_embed = Vimeo::Advanced::VideoEmbed.new("api_key", "secret")
|
|
273
|
+
|
|
274
|
+
video_embed.get_presets("auth_token", { :page => "1", :per_page => "25" })
|
|
275
|
+
video_embed.set_preset("auth_token", "video_id", "preset_id")
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
== Uploads
|
|
279
|
+
|
|
280
|
+
Uploads are a little bit tricky, so I figured I'd help you guys with a short tutorial.
|
|
281
|
+
|
|
282
|
+
# Start by creating an instance of the Upload class.
|
|
283
|
+
upload = Vimeo::Advanced::Upload.new("api_key", "secret")
|
|
284
|
+
# I'm going to assume you've got that user's auth token stored somewhere and that they have upload access.
|
|
285
|
+
auth_token = "..."
|
|
286
|
+
|
|
287
|
+
# Let's check the user's quota.
|
|
288
|
+
# You should let the user know if they don't have enough quota free and/or if their video can be uploaded in HD
|
|
289
|
+
quota = upload.get_quota(auth_token)
|
|
290
|
+
free_space = quota["user"]["upload_space"]["free"]
|
|
291
|
+
hd = quota["user"]["hq_quota"]
|
|
292
|
+
|
|
293
|
+
# Now let's get an upload ticket.
|
|
294
|
+
ticket = upload.get_ticket(auth_token)
|
|
295
|
+
ticket_id = get_ticket["ticket"]["id"]
|
|
296
|
+
endpoint = get_ticket["ticket"]["endpoint"]
|
|
297
|
+
|
|
298
|
+
# Cool! Let's post the video.
|
|
299
|
+
# The file path should be absolute.
|
|
300
|
+
file_path = "..."
|
|
301
|
+
json_manifest = upload.upload(auth_token, file_path, ticket_id, endpoint)
|
|
302
|
+
|
|
303
|
+
# After the upload completes...
|
|
304
|
+
upload.confirm(auth_token, ticket_id, json_manifest)
|
|
305
|
+
|
|
306
|
+
There are a few steps along the way where things can go wrong.
|
|
307
|
+
|
|
308
|
+
== Todo
|
|
309
|
+
|
|
310
|
+
* Better structure. There's too many classes. Is there a way to simplify the Advanced API?
|
|
311
|
+
* Advanced classes should be able to take the authentication token as a parameter so you don't have to pass it to the methods that require authentication.
|
|
312
|
+
* Error handling.
|
|
313
|
+
* Some methods are not implemented by Vimeo or don't seem to work.
|
|
314
|
+
* More re-factoring.
|
|
315
|
+
* Make tests more robust and faster. If anyone has any ideas let me know.
|
|
316
|
+
|
|
317
|
+
== Thanks to
|
|
318
|
+
|
|
319
|
+
* {HTTParty}[http://github.com/jnunemaker/httparty/tree/master]: Easily one of the best tools I have used since I started using Ruby.
|
|
320
|
+
* {Jeweler}[http://github.com/technicalpickles/jeweler/tree/master]: Great tool for creating gems for Github.
|
|
321
|
+
|
|
322
|
+
=== Copyright (c) 2008 Matt Hooks. See LICENSE for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake'
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'jeweler'
|
|
6
|
+
Jeweler::Tasks.new do |gem|
|
|
7
|
+
gem.name = "vimeo"
|
|
8
|
+
gem.summary = %Q{A full featured Ruby implementation of the Vimeo API.}
|
|
9
|
+
gem.description = %Q{A full featured Ruby implementation of the Vimeo API.}
|
|
10
|
+
gem.email = "matthooks@gmail.com"
|
|
11
|
+
gem.homepage = "http://github.com/matthooks/vimeo"
|
|
12
|
+
gem.authors = ["Matt Hooks"]
|
|
13
|
+
gem.rubyforge_project = "vimeo"
|
|
14
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 2.10.2"
|
|
15
|
+
gem.add_development_dependency "fakeweb", ">= 1.2.6"
|
|
16
|
+
gem.add_development_dependency "crack", ">= 0.1.4"
|
|
17
|
+
|
|
18
|
+
gem.has_rdoc = true
|
|
19
|
+
|
|
20
|
+
gem.rdoc_options = ['--main', 'README.rdoc', '--inline-source', '--charset=UTF-8']
|
|
21
|
+
gem.extra_rdoc_files = ['README.rdoc', 'LICENSE', 'CHANGELOG.rdoc']
|
|
22
|
+
|
|
23
|
+
gem.add_dependency "httparty", ">= 0.4.5"
|
|
24
|
+
gem.add_dependency "curb", ">= 0.5.4.0"
|
|
25
|
+
gem.add_dependency "json", ">= 1.1.9"
|
|
26
|
+
end
|
|
27
|
+
Jeweler::GemcutterTasks.new
|
|
28
|
+
rescue LoadError
|
|
29
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
require 'rake/testtask'
|
|
33
|
+
Rake::TestTask.new(:test) do |test|
|
|
34
|
+
test.libs << 'lib' << 'test'
|
|
35
|
+
test.pattern = 'test/**/*_test.rb'
|
|
36
|
+
test.verbose = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
begin
|
|
40
|
+
require 'rcov/rcovtask'
|
|
41
|
+
Rcov::RcovTask.new do |test|
|
|
42
|
+
test.libs << 'test'
|
|
43
|
+
test.pattern = 'test/**/*_test.rb'
|
|
44
|
+
test.verbose = true
|
|
45
|
+
end
|
|
46
|
+
rescue LoadError
|
|
47
|
+
task :rcov do
|
|
48
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
task :test => :check_dependencies
|
|
53
|
+
|
|
54
|
+
task :default => :test
|
|
55
|
+
|
|
56
|
+
require 'rake/rdoctask'
|
|
57
|
+
Rake::RDocTask.new do |rdoc|
|
|
58
|
+
if File.exist?('VERSION')
|
|
59
|
+
version = File.read('VERSION')
|
|
60
|
+
else
|
|
61
|
+
version = ""
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
65
|
+
rdoc.title = "vimeo #{version}"
|
|
66
|
+
rdoc.rdoc_files.include('README*')
|
|
67
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
68
|
+
end
|
data/VERSION.yml
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
module Vimeo
|
|
2
|
+
module Advanced
|
|
3
|
+
class Album < Vimeo::Advanced::Base
|
|
4
|
+
|
|
5
|
+
# Adds a video to an album.
|
|
6
|
+
create_api_method :add_video,
|
|
7
|
+
"vimeo.albums.addVideo",
|
|
8
|
+
:required => [:auth_token, :album_id, :video_id]
|
|
9
|
+
|
|
10
|
+
# Creates an album.
|
|
11
|
+
# FIXME: Nothing is returned if you add multiple videos to an album.
|
|
12
|
+
# The optional parameter videos is a comma-separated list of video ids.
|
|
13
|
+
create_api_method :create,
|
|
14
|
+
"vimeo.albums.create",
|
|
15
|
+
:required => [:auth_token, :title, :video_id],
|
|
16
|
+
:optional => [:description, :videos]
|
|
17
|
+
|
|
18
|
+
# Deletes an album.
|
|
19
|
+
create_api_method :delete,
|
|
20
|
+
"vimeo.albums.delete",
|
|
21
|
+
:required => [:auth_token, :album_id]
|
|
22
|
+
|
|
23
|
+
# Returns a list of a user's albums.
|
|
24
|
+
create_api_method :get_all,
|
|
25
|
+
"vimeo.albums.getAll",
|
|
26
|
+
:required => [:user_id],
|
|
27
|
+
:optional => [:page, :per_page, :sort]
|
|
28
|
+
|
|
29
|
+
# Returns a list of the videos in an album.
|
|
30
|
+
create_api_method :get_videos,
|
|
31
|
+
"vimeo.albums.getVideos",
|
|
32
|
+
:required => [:auth_token, :album_id],
|
|
33
|
+
:optional => [:page, :per_page, :full_response, :password]
|
|
34
|
+
|
|
35
|
+
# Removes a video from an album.
|
|
36
|
+
create_api_method :remove_video,
|
|
37
|
+
"vimeo.albums.removeVideo",
|
|
38
|
+
:required => [:auth_token, :album_id, :video_id]
|
|
39
|
+
|
|
40
|
+
# Sets the description of an album.
|
|
41
|
+
create_api_method :set_description,
|
|
42
|
+
"vimeo.albums.setDescription",
|
|
43
|
+
:required => [:auth_token, :album_id, :description]
|
|
44
|
+
|
|
45
|
+
# Sets the password of an album.
|
|
46
|
+
create_api_method :set_password,
|
|
47
|
+
"vimeo.albums.setPassword",
|
|
48
|
+
:required => [:auth_token, :album_id, :password]
|
|
49
|
+
|
|
50
|
+
# Sets the title of an album.
|
|
51
|
+
create_api_method :set_title,
|
|
52
|
+
"vimeo.albums.setTitle",
|
|
53
|
+
:required => [:auth_token, :album_id, :title]
|
|
54
|
+
|
|
55
|
+
end # Album
|
|
56
|
+
end # Advanced
|
|
57
|
+
end # Vimeo
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Vimeo
|
|
2
|
+
module Advanced
|
|
3
|
+
class Auth < Vimeo::Advanced::Base
|
|
4
|
+
|
|
5
|
+
# Tests the validity of an authorization token.
|
|
6
|
+
create_api_method :check_token,
|
|
7
|
+
"vimeo.auth.checkToken",
|
|
8
|
+
:required => [:auth_token]
|
|
9
|
+
|
|
10
|
+
# Obtains a frob.
|
|
11
|
+
# Used for desktop based authentication.
|
|
12
|
+
create_api_method :get_frob,
|
|
13
|
+
"vimeo.auth.getFrob"
|
|
14
|
+
|
|
15
|
+
# Obtains an authorization token.
|
|
16
|
+
create_api_method :get_token,
|
|
17
|
+
"vimeo.auth.getToken",
|
|
18
|
+
:required => [:frob]
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
end # Advanced
|
|
22
|
+
end # Vimeo
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
module CreateApiMethod
|
|
2
|
+
|
|
3
|
+
# Small DSL that creates a method that calls a Vimeo method through the advanced API.
|
|
4
|
+
#
|
|
5
|
+
# @param [String] method The name of the method being created.
|
|
6
|
+
# @param [String] vimeo_method The name of the advanced API Method the function should call.
|
|
7
|
+
# @param [Hash] options Some optional parameters.
|
|
8
|
+
# @option options [Array] :required An array of required parameters.
|
|
9
|
+
# @option options [Array] :optional An array of optional parameters.
|
|
10
|
+
# @option options [Array] :unsigned An array of required parameters that should not be included in the api_sig.
|
|
11
|
+
def create_api_method(method, vimeo_method, options={})
|
|
12
|
+
options = { :required => [], :optional => [], :unsigned => [] }.merge(options)
|
|
13
|
+
|
|
14
|
+
raise ArgumentError, 'Required parameters must be an array.' unless options[:required].is_a? Array
|
|
15
|
+
raise ArgumentError, 'Optional parameters must be an array.' unless options[:optional].is_a? Array
|
|
16
|
+
raise ArgumentError, 'Unsigned parameters must be an array.' unless options[:optional].is_a? Array
|
|
17
|
+
|
|
18
|
+
required = (options[:required] + options[:unsigned]).map { |r| r.to_s }.join(",")
|
|
19
|
+
required_hash = options[:required].map { |r| ":#{r} => #{r}" }.join(",")
|
|
20
|
+
optional_hash = options[:optional].map { |o| ":#{o} => nil" }.join(",")
|
|
21
|
+
unsigned_hash = options[:unsigned].map { |u| ":#{u} => #{u}" }.join(",")
|
|
22
|
+
|
|
23
|
+
parameters = "(#{required unless required.blank?}#{',' unless required.blank?}options={#{optional_hash}})"
|
|
24
|
+
|
|
25
|
+
method_string = <<-method
|
|
26
|
+
|
|
27
|
+
def #{method}#{parameters}
|
|
28
|
+
raise ArgumentError, 'Options must be a hash.' unless options.is_a? Hash
|
|
29
|
+
|
|
30
|
+
sig_options = {
|
|
31
|
+
:method => "#{vimeo_method}",
|
|
32
|
+
:format => "json"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
#{ options[:required].map { |r| "sig_options.merge! :#{r} => #{r}"}.join("\n") }
|
|
36
|
+
#{ options[:optional].map { |o| "sig_options.merge! :#{o} => options[:#{o}] unless options[:#{o}].nil?" }.join("\n") }
|
|
37
|
+
|
|
38
|
+
make_request sig_options#{ ", :unsigned => {" + unsigned_hash + "}" unless options[:unsigned].empty? }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
method
|
|
42
|
+
|
|
43
|
+
class_eval method_string
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
module Vimeo
|
|
49
|
+
module Advanced
|
|
50
|
+
|
|
51
|
+
class Base
|
|
52
|
+
include HTTParty
|
|
53
|
+
base_uri 'vimeo.com'
|
|
54
|
+
extend CreateApiMethod
|
|
55
|
+
|
|
56
|
+
# TODO: Pass an auth token, if you've already got one
|
|
57
|
+
# TODO: implement format_options
|
|
58
|
+
# Requires your API key and secret phrase.
|
|
59
|
+
# The API key and secret are prepended to every request.
|
|
60
|
+
def initialize(api_key, secret, format_options={})
|
|
61
|
+
@auth = { :api_key => api_key }
|
|
62
|
+
@secret = secret
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Generates a link that allows a user to authorize
|
|
66
|
+
# your web application to use the advanced API
|
|
67
|
+
def web_login_link(perms)
|
|
68
|
+
api_sig = generate_api_sig :perms => perms
|
|
69
|
+
"http://vimeo.com/services/auth/?api_key=#{@auth[:api_key]}&perms=#{perms}&api_sig=#{api_sig}"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Generates a link that allows a user to authorize
|
|
73
|
+
# your desktop application to use the advanced API
|
|
74
|
+
def desktop_login_link(perms, frob)
|
|
75
|
+
api_sig = generate_api_sig :frob => frob, :perms => perms
|
|
76
|
+
"http://vimeo.com/services/auth/?api_key=#{@auth[:api_key]}&perms=#{perms}&frob=#{frob}&api_sig=#{api_sig}"
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
private
|
|
80
|
+
|
|
81
|
+
def make_request(sig_options, options={})
|
|
82
|
+
options = { :unsigned => [] }.merge(options)
|
|
83
|
+
unsigned = options[:unsigned]
|
|
84
|
+
|
|
85
|
+
api_sig = generate_api_sig sig_options
|
|
86
|
+
self.class.post "/api/rest/v2", :query => query(sig_options, api_sig), :body => unsigned
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Generates a MD5 hashed API signature for Advanced API requests
|
|
90
|
+
def generate_api_sig(options={})
|
|
91
|
+
# Every request requires the api_key parameter
|
|
92
|
+
options.merge! @auth
|
|
93
|
+
# Keys must be sorted alphabetically
|
|
94
|
+
api_sig = options.sort { |a, b| a.to_s <=> b.to_s }.join
|
|
95
|
+
Digest::MD5.hexdigest("#{@secret}#{api_sig}")
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def query(sig_options, api_sig)
|
|
99
|
+
sig_options.merge :api_key => @auth[:api_key], :api_sig => api_sig
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
end # Base
|
|
103
|
+
|
|
104
|
+
end # Advanced
|
|
105
|
+
end # Vimeo
|