simple_youtube 3.0.1 → 4.0.1
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/README.markdown +28 -31
- data/lib/simple_youtube.rb +2 -0
- data/lib/simple_youtube/version.rb +1 -1
- data/lib/simple_youtube/youtube.rb +8 -8
- data/simple_youtube.gemspec +1 -0
- data/spec/youtube_update_spec.rb +8 -28
- metadata +63 -17
data/README.markdown
CHANGED
@@ -2,7 +2,7 @@ simple_youtube works with the YouTube v2 API to...
|
|
2
2
|
|
3
3
|
1) Read(:get) YouTube data with no API Key
|
4
4
|
|
5
|
-
2) Update(:put) YouTube video data using your Gdata API Key and
|
5
|
+
2) Update(:put) YouTube video data using your Gdata API Key and OAuth2(v3 of this gem uses OAuth1). Pass in your OAuth2 access token, created using the [omniauth-youtube](https://github.com/jamiew/omniauth-youtube) OAuth2 set up in Rails. Beforehand you'll also need to [authenticate and authorize your host to use the Google APIs](https://developers.google.com/youtube/registering_an_application) to set up the correct keys
|
6
6
|
|
7
7
|
3) Currently no Create or Delete functionality.
|
8
8
|
|
@@ -28,8 +28,8 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
28
28
|
video_search.entry.size # => 5
|
29
29
|
video_search.title # => "YouTube Videos matching query: ruby on rails"
|
30
30
|
video_search.entry[3].link[1].href # => http://gdata.youtube.com/feeds/api/videos/UCB57Npj9U0/responses?v=2
|
31
|
-
|
32
|
-
|
31
|
+
|
32
|
+
|
33
33
|
### :get related videos
|
34
34
|
|
35
35
|
[http://gdata.youtube.com/feeds/api/videos/rFVHjZYoq4Q/related?v=2](http://gdata.youtube.com/feeds/api/videos/rFVHjZYoq4Q/related?v=2)
|
@@ -37,7 +37,7 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
37
37
|
video_related = Youtube::Video.find(:scope => 'rFVHjZYoq4Q', :type => 'related', :params => {:v => '2'})
|
38
38
|
video_related.entry.size # => 25
|
39
39
|
video_related.entry[24].author.uri # => http://gdata.youtube.com/feeds/api/users/neodracco
|
40
|
-
|
40
|
+
|
41
41
|
|
42
42
|
### :get video responses
|
43
43
|
|
@@ -45,7 +45,7 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
45
45
|
|
46
46
|
video_responses = Youtube::Video.find(:scope => 'rFVHjZYoq4Q', :type => 'responses', :params => {:v => '2'})
|
47
47
|
video_responses.entry[1].group.category # => Music
|
48
|
-
|
48
|
+
|
49
49
|
|
50
50
|
### :get video comments
|
51
51
|
|
@@ -53,7 +53,7 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
53
53
|
|
54
54
|
video_comments = Youtube::Video.find(:scope => 'rFVHjZYoq4Q', :type => 'comments', :params => {:v => '2'})
|
55
55
|
video_comments.entry[0].content # => Come up to my first ever e on this about 14-15 years ago, ahh too long...
|
56
|
-
|
56
|
+
|
57
57
|
|
58
58
|
### :get top 11 videos in Comedy category/tag
|
59
59
|
|
@@ -63,7 +63,7 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
63
63
|
video_category.entry.size # => 11
|
64
64
|
video_category.entry[9].category[2].term # => Harry Potter
|
65
65
|
video_category.entry[0].category[1].term # => Comedy
|
66
|
-
|
66
|
+
|
67
67
|
|
68
68
|
### :get top 5 videos in Comedy category/tag, excluding Film category/tag
|
69
69
|
|
@@ -72,7 +72,7 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
72
72
|
video_category_comedy_exclude_film = Youtube::Video.find(:params => {:category => 'Comedy,-Film', :"max-results" => '5', :v => '2'})
|
73
73
|
video_category_comedy_exclude_film.entry[1].category.size # => 18
|
74
74
|
video_category_comedy_exclude_film.entry[1].category.each { |category| puts 'film' if category.term.eql?('Film') } #=> nil
|
75
|
-
|
75
|
+
|
76
76
|
|
77
77
|
### :get videos in david, beckham,(News or Sports) category/tags
|
78
78
|
|
@@ -81,30 +81,27 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
81
81
|
video_category_david_beckham_news_or_sports = Youtube::Video.find(:params => {:category => 'david,beckham,News|Sports', :v => '2'})
|
82
82
|
video_category_david_beckham_news_or_sports.entry[7].category[1].label # => Sports
|
83
83
|
video_category_david_beckham_news_or_sports.entry[7].category[2].term # => david
|
84
|
-
|
84
|
+
|
85
85
|
### :put an updated video
|
86
86
|
|
87
87
|
video_uid = "video_uid"
|
88
88
|
user_name = "user_name"
|
89
89
|
update_xml = IO.read('fixture/video_update.xml')
|
90
90
|
oauth_token = "oauth_token"
|
91
|
-
oauth_token_secret = "oauth_token_secret"
|
92
91
|
x_gdata_key = "x_gdata_key"
|
93
|
-
|
94
|
-
host_secret = "host_secret"
|
95
|
-
|
92
|
+
|
96
93
|
response = Youtube::Video.update(video_uid, user_name, update_xml, oauth_token, oauth_token_secret, x_gdata_key, host, host_secret)
|
97
|
-
response.code # => 200
|
98
|
-
|
94
|
+
response.code # => 200
|
95
|
+
|
99
96
|
## Standardfeed
|
100
|
-
|
97
|
+
|
101
98
|
### :get top rated videos from today
|
102
99
|
|
103
100
|
[http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today&v=2](http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today&v=2)
|
104
101
|
|
105
102
|
standardfeed_topratedtoday = Youtube::Standardfeed.find(:type => 'top_rated', :params => {:time => 'today', :v => '2'})
|
106
103
|
standardfeed_topratedtoday.entry[16].author.name = "ZOMGitsCriss"
|
107
|
-
|
104
|
+
|
108
105
|
### :get top rated videos from jp
|
109
106
|
|
110
107
|
[http://gdata.youtube.com/feeds/api/standardfeeds/JP/top_rated?v=2](http://gdata.youtube.com/feeds/api/standardfeeds/JP/top_rated?v=2)
|
@@ -112,57 +109,57 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
112
109
|
standardfeed_toprated_jp = Youtube::Standardfeed.find(:scope => 'JP', :type => 'top_rated', :params => {:v => '2'})
|
113
110
|
standardfeed_toprated_jp.id = "tag:youtube.com,2008:standardfeed:jp:top_rated"
|
114
111
|
standardfeed_toprated_jp.entry[1].link[4].href = "http://gdata.youtube.com/feeds/api/standardfeeds/jp/top_rated/v/BQ9YtJC-Kd8?v=2"
|
115
|
-
|
116
|
-
|
112
|
+
|
113
|
+
|
117
114
|
### :get top rated comedy videos from jp
|
118
|
-
|
115
|
+
|
119
116
|
[http://gdata.youtube.com/feeds/api/standardfeeds/JP/top_rated?category=Comedy&max-results=11&v=2]("http://gdata.youtube.com/feeds/api/standardfeeds/jp/top_rated/v/7hYGkqc1gqE?v=2")
|
120
117
|
|
121
118
|
standardfeed_toprated_jp_comedy = Youtube::Standardfeed.find(:scope => 'JP', :type => 'top_rated', :params => {:category => 'Comedy', :"max-results" => '11', :v => '2'})
|
122
119
|
standardfeed_toprated_jp_comedy.entry[1].link[4].href = "http://gdata.youtube.com/feeds/api/standardfeeds/jp/top_rated/v/7hYGkqc1gqE?v=2"
|
123
120
|
|
124
121
|
|
125
|
-
## User
|
122
|
+
## User
|
126
123
|
|
127
124
|
### :get a single user
|
128
125
|
|
129
126
|
[http://gdata.youtube.com/feeds/api/users/neodracco](http://gdata.youtube.com/feeds/api/users/neodracco)
|
130
|
-
|
127
|
+
|
131
128
|
user_search = Youtube::User.find(:scope => 'neodracco')
|
132
129
|
user_search.entry.size => 1
|
133
130
|
|
134
131
|
### :get ionysis favourite videos
|
135
|
-
|
132
|
+
|
136
133
|
[http://gdata.youtube.com/feeds/api/users/ionysis/favorites?v=2](http://gdata.youtube.com/feeds/api/users/ionysis/favorites?v=2)
|
137
134
|
|
138
135
|
user_ionysis_favourites = Youtube::User.find(:scope => 'ionysis', :type => 'favorites', :params => {:v => '2'})
|
139
136
|
user_ionysis_favourites.entry[7].statistics.favoriteCount) = "9586"
|
140
137
|
user_ionysis_favourites.entry[7].rating[1].numLikes) = "2568"
|
141
|
-
|
138
|
+
|
142
139
|
### :get cyanure1982 playlists
|
143
140
|
|
144
141
|
[http://gdata.youtube.com/feeds/api/users/cyanure1982/playlists?v=2](http://gdata.youtube.com/feeds/api/users/cyanure1982/playlists?v=2)
|
145
142
|
|
146
143
|
user_cyanure1982_playlists = Youtube::User.find(:scope => 'cyanure1982', :type => 'playlists', :params => {:v => '2'})
|
147
144
|
user_cyanure1982_playlists.entry[2].title) = "shinnenkai"
|
148
|
-
|
145
|
+
|
149
146
|
### :get ionysis subscriptions
|
150
147
|
|
151
148
|
[http://gdata.youtube.com/feeds/api/users/ionysis/subscriptions?v=2](http://gdata.youtube.com/feeds/api/users/ionysis/subscriptions?v=2)
|
152
149
|
|
153
150
|
user_ionysis_subscriptions = Youtube::User.find(:scope => 'ionysis', :type => 'subscriptions', :params => {:v => '2'})
|
154
151
|
user_ionysis_subscriptions.entry[0].title) = "Videos published by : vinyljunkie07"
|
155
|
-
|
152
|
+
|
156
153
|
### :get vinyljunkie07 contacts
|
157
154
|
|
158
155
|
[http://gdata.youtube.com/feeds/api/users/vinyljunkie07/contacts?v=2](http://gdata.youtube.com/feeds/api/users/vinyljunkie07/contacts?v=2)
|
159
156
|
|
160
157
|
user_vinyljunkie07_contacts = Youtube::User.find(:scope => 'vinyljunkie07', :type => 'contacts', :params => {:v => '2'})
|
161
158
|
user_vinyljunkie07_contacts.entry[18].id) "tag:youtube.com,2008:user:vinyljunkie07:contact:CrackerSchool"
|
162
|
-
|
163
159
|
|
164
|
-
|
165
|
-
|
160
|
+
|
161
|
+
## Playlist
|
162
|
+
|
166
163
|
### :get the cyanure1982 playlist - shinnenkai(D00BDE6AA710D50C)
|
167
164
|
|
168
165
|
[http://gdata.youtube.com/feeds/api/playlists/D00BDE6AA710D50C?max-results=14&v=2](http://gdata.youtube.com/feeds/api/playlists/D00BDE6AA710D50C?max-results=14&v=2)
|
@@ -170,9 +167,9 @@ I have tried to cover most of the examples from the [YouTube API reference](http
|
|
170
167
|
playlist_cyanure1982 = Youtube::Playlist.find(:scope => 'D00BDE6AA710D50C', :params => {:"max-results" => '14', :v => '2'})
|
171
168
|
playlist_cyanure1982.entry.size = 14
|
172
169
|
playlist_cyanure1982.entry[7].group.keywords = "nu, jazz, club, house, Jazztronik, dj, Yukihiro, Fukutomi, Mondo, Grosso, Daishi, Dance, FreeTEMPO, FPM, KJM, Kentaro, Takizawa"
|
173
|
-
|
170
|
+
|
174
171
|
simple_youtube is derived from the active_youtube gem from the [Quark ruby blog](http://www.quarkruby.com/2008/2/12/active-youtube)
|
175
|
-
|
172
|
+
|
176
173
|
Big Thanks to the Quark crew for the inspiration!!!
|
177
174
|
|
178
175
|
|
data/lib/simple_youtube.rb
CHANGED
@@ -2,15 +2,16 @@ require 'oauth'
|
|
2
2
|
|
3
3
|
#### Create classes for YouTube resources.
|
4
4
|
module Youtube
|
5
|
-
|
6
5
|
class Video < ActiveYoutube
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
def self.update scope, user_name, update_xml, oauth_token, x_gdata_key
|
7
|
+
RestClient.put(
|
8
|
+
"http://gdata.youtube.com/feeds/api/users/#{user_name}/uploads/#{scope}",
|
9
|
+
update_xml,
|
10
|
+
{ 'Authorization' => "Bearer #{oauth_token}",
|
11
|
+
'Content-Type' => 'application/atom+xml',
|
12
|
+
'GData-Version' => '2',
|
13
|
+
'X-GData-Key' => "key=#{x_gdata_key}" })
|
12
14
|
end
|
13
|
-
|
14
15
|
end
|
15
16
|
|
16
17
|
class User < ActiveYoutube
|
@@ -21,5 +22,4 @@ module Youtube
|
|
21
22
|
|
22
23
|
class Playlist < ActiveYoutube
|
23
24
|
end
|
24
|
-
|
25
25
|
end
|
data/simple_youtube.gemspec
CHANGED
data/spec/youtube_update_spec.rb
CHANGED
@@ -2,49 +2,29 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'YoutubeUpdateSpec' do
|
4
4
|
it 'updates a video on youtube' do
|
5
|
-
|
5
|
+
|
6
6
|
access_token = double('access_token')
|
7
|
-
host = 'www.host.com'
|
8
|
-
host_secret = 'host_secret'
|
9
7
|
oauth_token = 'oauth_token'
|
10
|
-
oauth_token_secret = "oauth_token_secret"
|
11
8
|
x_gdata_key = 'x_gdata_key'
|
12
9
|
video_uid = 'video_uid'
|
13
10
|
user_name = 'user_name'
|
14
11
|
update_xml = IO.read(SimpleYoutube::ROOT + '/spec/fixture/video_update.xml')
|
15
12
|
|
16
|
-
|
17
|
-
with(
|
18
|
-
host,
|
19
|
-
host_secret,
|
20
|
-
{ :site => 'https://www.google.com',
|
21
|
-
:request_token_path => '/accounts/OAuthGetRequestToken',
|
22
|
-
:authorize_path => '/accounts/OAuthAuthorizeToken',
|
23
|
-
:access_token_path => '/accounts/OAuthGetAccessToken' }).
|
24
|
-
and_return(consumer)
|
25
|
-
|
26
|
-
OAuth::AccessToken.should_receive(:new).
|
27
|
-
with(consumer, oauth_token, oauth_token_secret).
|
28
|
-
and_return(access_token)
|
29
|
-
|
30
|
-
access_token.should_receive(:put).
|
31
|
-
with(
|
13
|
+
RestClient.should_receive(:put).with(
|
32
14
|
"http://gdata.youtube.com/feeds/api/users/#{user_name}/uploads/#{video_uid}",
|
33
15
|
update_xml,
|
34
|
-
{ '
|
35
|
-
'Content-Type'
|
36
|
-
'
|
37
|
-
|
16
|
+
{ 'Authorization' => "Bearer #{oauth_token}",
|
17
|
+
'Content-Type' => 'application/atom+xml',
|
18
|
+
'GData-Version' => '2',
|
19
|
+
'X-GData-Key' => "key=#{x_gdata_key}" }).
|
20
|
+
and_return(Net::HTTPResponse.new(1.1, 200, 'OK'))
|
38
21
|
|
39
22
|
response = Youtube::Video.update(
|
40
23
|
video_uid,
|
41
24
|
user_name,
|
42
25
|
update_xml,
|
43
26
|
oauth_token,
|
44
|
-
|
45
|
-
x_gdata_key,
|
46
|
-
host,
|
47
|
-
host_secret)
|
27
|
+
x_gdata_key)
|
48
28
|
|
49
29
|
response.code.should == 200
|
50
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_youtube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activeresource
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.1'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: oauth
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,31 @@ dependencies:
|
|
32
37
|
version: '0.4'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0.4'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rest-client
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
36
62
|
- !ruby/object:Gem::Dependency
|
37
63
|
name: fakeweb
|
38
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
39
65
|
none: false
|
40
66
|
requirements:
|
41
67
|
- - ~>
|
@@ -43,10 +69,15 @@ dependencies:
|
|
43
69
|
version: '1.3'
|
44
70
|
type: :development
|
45
71
|
prerelease: false
|
46
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.3'
|
47
78
|
- !ruby/object:Gem::Dependency
|
48
79
|
name: rspec
|
49
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
50
81
|
none: false
|
51
82
|
requirements:
|
52
83
|
- - ~>
|
@@ -54,10 +85,15 @@ dependencies:
|
|
54
85
|
version: '2.6'
|
55
86
|
type: :development
|
56
87
|
prerelease: false
|
57
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '2.6'
|
58
94
|
- !ruby/object:Gem::Dependency
|
59
95
|
name: debugger
|
60
|
-
requirement:
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
61
97
|
none: false
|
62
98
|
requirements:
|
63
99
|
- - ! '>='
|
@@ -65,10 +101,15 @@ dependencies:
|
|
65
101
|
version: '0'
|
66
102
|
type: :development
|
67
103
|
prerelease: false
|
68
|
-
version_requirements:
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
69
110
|
- !ruby/object:Gem::Dependency
|
70
111
|
name: rake
|
71
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
72
113
|
none: false
|
73
114
|
requirements:
|
74
115
|
- - ! '>='
|
@@ -76,7 +117,12 @@ dependencies:
|
|
76
117
|
version: '0'
|
77
118
|
type: :development
|
78
119
|
prerelease: false
|
79
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
80
126
|
description: ActiveResource extension to Gdata Youtube API, anonymous Reads, Updates
|
81
127
|
using your API key and OAuth, no Create or Delete access.
|
82
128
|
email:
|
@@ -133,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
133
179
|
version: '0'
|
134
180
|
segments:
|
135
181
|
- 0
|
136
|
-
hash:
|
182
|
+
hash: -62510107833783057
|
137
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
184
|
none: false
|
139
185
|
requirements:
|
@@ -142,10 +188,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
188
|
version: '0'
|
143
189
|
segments:
|
144
190
|
- 0
|
145
|
-
hash:
|
191
|
+
hash: -62510107833783057
|
146
192
|
requirements: []
|
147
193
|
rubyforge_project: simple_youtube
|
148
|
-
rubygems_version: 1.8.
|
194
|
+
rubygems_version: 1.8.25
|
149
195
|
signing_key:
|
150
196
|
specification_version: 3
|
151
197
|
summary: ActiveResource extension to Gdata Youtube API.
|