youtube_it 2.1.3 → 2.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rake', '0.8.7'
4
- gem 'oauth', '0.4.4'
5
- gem 'oauth2', '0.5.2'
6
- gem 'simple_oauth', '0.1.5'
7
- gem 'faraday', '0.7.3'
3
+ gem 'oauth', '~> 0.4.4'
4
+ gem 'oauth2', '~> 0.5.2'
5
+ gem 'simple_oauth', '~> 0.1.5'
6
+ gem 'faraday', '~> 0.7.3'
7
+ gem 'jeweler', '~> 1.8.3'
8
8
  gem 'builder'
9
9
 
10
10
  group :test do
11
- gem 'webmock'
11
+ gem 'webmock', '~> 1.7.10'
12
12
  end
data/Gemfile.lock CHANGED
@@ -1,21 +1,30 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- addressable (2.2.6)
4
+ addressable (2.2.7)
5
5
  builder (3.0.0)
6
6
  crack (0.3.1)
7
- faraday (0.7.3)
8
- addressable (~> 2.2.6)
9
- multipart-post (~> 1.1.0)
10
- rack (>= 1.1.0, < 2)
7
+ faraday (0.7.6)
8
+ addressable (~> 2.2)
9
+ multipart-post (~> 1.1)
10
+ rack (~> 1.1)
11
+ git (1.2.5)
12
+ jeweler (1.8.3)
13
+ bundler (~> 1.0)
14
+ git (>= 1.2.5)
15
+ rake
16
+ rdoc
17
+ json (1.6.5)
11
18
  multi_json (1.0.4)
12
- multipart-post (1.1.4)
13
- oauth (0.4.4)
19
+ multipart-post (1.1.5)
20
+ oauth (0.4.5)
14
21
  oauth2 (0.5.2)
15
22
  faraday (~> 0.7)
16
23
  multi_json (~> 1.0)
17
24
  rack (1.4.1)
18
- rake (0.8.7)
25
+ rake (0.9.2.2)
26
+ rdoc (3.12)
27
+ json (~> 1.4)
19
28
  simple_oauth (0.1.5)
20
29
  webmock (1.7.10)
21
30
  addressable (~> 2.2, > 2.2.5)
@@ -26,9 +35,9 @@ PLATFORMS
26
35
 
27
36
  DEPENDENCIES
28
37
  builder
29
- faraday (= 0.7.3)
30
- oauth (= 0.4.4)
31
- oauth2 (= 0.5.2)
32
- rake (= 0.8.7)
33
- simple_oauth (= 0.1.5)
34
- webmock
38
+ faraday (~> 0.7.3)
39
+ jeweler (~> 1.8.3)
40
+ oauth (~> 0.4.4)
41
+ oauth2 (~> 0.5.2)
42
+ simple_oauth (~> 0.1.5)
43
+ webmock (~> 1.7.10)
data/README.rdoc CHANGED
@@ -1,3 +1,12 @@
1
+ == DONATION
2
+
3
+ YOUTUBE_IT is developed by many contributors who are passioned about opensource projects
4
+ and selflessly donate their time and work. Following that spirit your donations to this project
5
+ will be destined to the Tuquito Libre Foundation(http://fundacion.tuquito.org.ar) for developing
6
+ technology projects intended to close the digital gap in Latin America.
7
+
8
+ {<img src=https://www.pledgie.com/campaigns/16746.png?skin_name=chrome>}[http://www.pledgie.com/campaigns/16746]
9
+
1
10
  == DESCRIPTION
2
11
 
3
12
  youtube_it is the most complete Ruby client for the YouTube GData API. It provides an easy
@@ -43,7 +52,7 @@ Client with OAuth:
43
52
  $ client.authorize_from_access("access_token", "access_secret")
44
53
 
45
54
  Client with OAuth2:
46
- $ client = YouTubeIt::OAuth2Client.new(client_access_token: "access_token", client_refresh_token: "refresh_token", client_id: "client_id", client_secret: "client_secret", dev_key: "dev_key")
55
+ $ client = YouTubeIt::OAuth2Client.new(client_access_token: "access_token", client_refresh_token: "refresh_token", client_id: "client_id", client_secret: "client_secret", dev_key: "dev_key", expires_at: "expiration time")
47
56
 
48
57
  If your access token is still valid (be careful, access tokens may only be valid for about 1 hour), you can use the client directly. If you want to refresh the access token using the refresh token just do:
49
58
 
data/Rakefile CHANGED
@@ -1,26 +1,28 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'rubygems'
2
- gem 'rake', '0.9.2.2'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :test)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
3
12
  require 'rake'
4
13
 
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "youtube_it"
9
- gem.summary = %Q{The most complete Ruby wrapper for youtube api's}
10
- gem.description = %Q{Upload, delete, update, comment on youtube videos all from one gem.}
11
- gem.email = "kylejginavan@gmail.com"
12
- gem.homepage = "http://github.com/kylejginavan/youtube_it"
13
- gem.add_dependency('oauth','>=0.4.4')
14
- gem.add_dependency('oauth2','>=0.5.2')
15
- gem.add_dependency('simple_oauth', '>=0.1.5')
16
- gem.add_dependency('faraday','>=0.7.3')
17
- gem.add_dependency('builder')
18
- gem.authors = ["kylejginavan","chebyte", "mseppae"]
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "youtube_it (or a dependency) not available. Install it with: gem install youtube_it"
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "youtube_it"
18
+ gem.summary = %Q{The most complete Ruby wrapper for youtube api's}
19
+ gem.description = %Q{Upload, delete, update, comment on youtube videos all from one gem.}
20
+ gem.email = "kylejginavan@gmail.com"
21
+ gem.homepage = "http://github.com/kylejginavan/youtube_it"
22
+ gem.authors = ["kylejginavan","chebyte", "mseppae"]
23
+ # dependencies defined in Gemfile
23
24
  end
25
+ Jeweler::RubygemsDotOrgTasks.new
24
26
 
25
27
  require 'rake/testtask'
26
28
  Rake::TestTask.new(:test) do |test|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.3
1
+ 2.1.4
@@ -407,11 +407,12 @@ class YouTubeIt
407
407
 
408
408
  class OAuth2Client < YouTubeIt::Client
409
409
  def initialize(options)
410
- @client_id = options[:client_id]
411
- @client_secret = options[:client_secret]
412
- @client_access_token = options[:client_access_token]
413
- @client_refresh_token = options[:client_refresh_token]
414
- @dev_key = options[:dev_key]
410
+ @client_id = options[:client_id]
411
+ @client_secret = options[:client_secret]
412
+ @client_access_token = options[:client_access_token]
413
+ @client_refresh_token = options[:client_refresh_token]
414
+ @client_token_expires_at = options[:client_token_expires_at]
415
+ @dev_key = options[:dev_key]
415
416
  end
416
417
 
417
418
  def oauth_client
@@ -422,7 +423,7 @@ class YouTubeIt
422
423
  end
423
424
 
424
425
  def access_token
425
- @access_token ||= ::OAuth2::AccessToken.new(oauth_client, @client_access_token, :refresh_token => @client_refresh_token)
426
+ @access_token ||= ::OAuth2::AccessToken.new(oauth_client, @client_access_token, :refresh_token => @client_refresh_token, :expires_at => @client_token_expires_at)
426
427
  end
427
428
 
428
429
  def refresh_access_token!
@@ -149,7 +149,7 @@ class YouTubeIt
149
149
  # === Returns
150
150
  # String: The Youtube video id.
151
151
  def unique_id
152
- video_id[/videos\/([^<]+)/, 1] || video_id[/video\:([^<]+)/, 1]
152
+ @unique_id || video_id[/videos\/([^<]+)/, 1] || video_id[/video\:([^<]+)/, 1]
153
153
  end
154
154
 
155
155
  # Allows you to check whether the video can be embedded on a webpage.
@@ -374,6 +374,11 @@ class YouTubeIt
374
374
  end
375
375
  media_group = entry.elements["media:group"]
376
376
 
377
+ ytid = nil
378
+ unless media_group.elements["yt:videoid"].nil?
379
+ ytid = media_group.elements["yt:videoid"].text
380
+ end
381
+
377
382
  # if content is not available on certain region, there is no media:description, media:player or yt:duration
378
383
  description = ""
379
384
  unless media_group.elements["media:description"].nil?
@@ -482,7 +487,8 @@ class YouTubeIt
482
487
  :position => position,
483
488
  :latitude => latitude,
484
489
  :longitude => longitude,
485
- :state => state)
490
+ :state => state,
491
+ :unique_id => ytid)
486
492
  end
487
493
 
488
494
  def parse_media_content (media_content_element)
data/test/test_client.rb CHANGED
@@ -253,6 +253,16 @@ class TestClient < Test::Unit::TestCase
253
253
  assert @client.delete_playlist(playlist.playlist_id)
254
254
  end
255
255
 
256
+ def test_should_return_unique_id_from_playlist
257
+ playlist = @client.add_playlist(:title => "youtube_it test!", :description => "test playlist")
258
+ video = @client.add_video_to_playlist(playlist.playlist_id,"CE62FSEoY28")
259
+
260
+ assert_equal "CE62FSEoY28", playlist.videos.last.unique_id
261
+
262
+ assert @client.delete_video_from_playlist(playlist.playlist_id, video[:playlist_entry_id])
263
+ assert @client.delete_playlist(playlist.playlist_id)
264
+ end
265
+
256
266
  def test_should_add_and_delete_new_playlist
257
267
  result = @client.add_playlist(:title => "youtube_it test4!", :description => "test playlist")
258
268
  assert result.title, "youtube_it test!"
@@ -314,21 +324,24 @@ class TestClient < Test::Unit::TestCase
314
324
 
315
325
  def test_should_subscribe_to_channel
316
326
  r = @client.subscribe_channel("TheWoWArthas")
327
+ sleep(4)
317
328
  assert_equal r[:code], 201
318
- assert_equal @client.subscriptions.first.title, "Videos published by : TheWoWArthas"
329
+ assert_equal @client.subscriptions.first.title, "Videos published by: TheWoWArthas"
319
330
  @client.unsubscribe_channel(@client.subscriptions.first.id)
320
331
  end
321
332
 
322
333
  def test_should_unsubscribe_to_channel
323
334
  @client.subscribe_channel("TheWoWArthas")
335
+ sleep(4)
324
336
  r = @client.unsubscribe_channel(@client.subscriptions.first.id)
325
337
  assert_equal r[:code], 200
326
338
  end
327
339
 
328
340
  def test_should_list_subscriptions
329
341
  @client.subscribe_channel("TheWoWArthas")
342
+ sleep(4)
330
343
  assert @client.subscriptions.count == 1
331
- assert_equal @client.subscriptions.first.title, "Videos published by : TheWoWArthas"
344
+ assert_equal @client.subscriptions.first.title, "Videos published by: TheWoWArthas"
332
345
  @client.unsubscribe_channel(@client.subscriptions.first.id)
333
346
  end
334
347
 
data/youtube_it.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{youtube_it}
8
- s.version = "2.1.3"
8
+ s.version = "2.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kylejginavan", "chebyte", "mseppae"]
12
- s.date = %q{2012-02-06}
12
+ s.date = %q{2012-02-23}
13
13
  s.description = %q{Upload, delete, update, comment on youtube videos all from one gem.}
14
14
  s.email = %q{kylejginavan@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -73,41 +73,26 @@ Gem::Specification.new do |s|
73
73
  s.specification_version = 3
74
74
 
75
75
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
76
- s.add_runtime_dependency(%q<rake>, ["= 0.8.7"])
77
- s.add_runtime_dependency(%q<oauth>, ["= 0.4.4"])
78
- s.add_runtime_dependency(%q<oauth2>, ["= 0.5.2"])
79
- s.add_runtime_dependency(%q<simple_oauth>, ["= 0.1.5"])
80
- s.add_runtime_dependency(%q<faraday>, ["= 0.7.3"])
81
- s.add_runtime_dependency(%q<builder>, [">= 0"])
82
- s.add_runtime_dependency(%q<oauth>, [">= 0.4.4"])
83
- s.add_runtime_dependency(%q<oauth2>, [">= 0.5.2"])
84
- s.add_runtime_dependency(%q<simple_oauth>, [">= 0.1.5"])
85
- s.add_runtime_dependency(%q<faraday>, [">= 0.7.3"])
76
+ s.add_runtime_dependency(%q<oauth>, ["~> 0.4.4"])
77
+ s.add_runtime_dependency(%q<oauth2>, ["~> 0.5.2"])
78
+ s.add_runtime_dependency(%q<simple_oauth>, ["~> 0.1.5"])
79
+ s.add_runtime_dependency(%q<faraday>, ["~> 0.7.3"])
80
+ s.add_runtime_dependency(%q<jeweler>, ["~> 1.8.3"])
86
81
  s.add_runtime_dependency(%q<builder>, [">= 0"])
87
82
  else
88
- s.add_dependency(%q<rake>, ["= 0.8.7"])
89
- s.add_dependency(%q<oauth>, ["= 0.4.4"])
90
- s.add_dependency(%q<oauth2>, ["= 0.5.2"])
91
- s.add_dependency(%q<simple_oauth>, ["= 0.1.5"])
92
- s.add_dependency(%q<faraday>, ["= 0.7.3"])
93
- s.add_dependency(%q<builder>, [">= 0"])
94
- s.add_dependency(%q<oauth>, [">= 0.4.4"])
95
- s.add_dependency(%q<oauth2>, [">= 0.5.2"])
96
- s.add_dependency(%q<simple_oauth>, [">= 0.1.5"])
97
- s.add_dependency(%q<faraday>, [">= 0.7.3"])
83
+ s.add_dependency(%q<oauth>, ["~> 0.4.4"])
84
+ s.add_dependency(%q<oauth2>, ["~> 0.5.2"])
85
+ s.add_dependency(%q<simple_oauth>, ["~> 0.1.5"])
86
+ s.add_dependency(%q<faraday>, ["~> 0.7.3"])
87
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
98
88
  s.add_dependency(%q<builder>, [">= 0"])
99
89
  end
100
90
  else
101
- s.add_dependency(%q<rake>, ["= 0.8.7"])
102
- s.add_dependency(%q<oauth>, ["= 0.4.4"])
103
- s.add_dependency(%q<oauth2>, ["= 0.5.2"])
104
- s.add_dependency(%q<simple_oauth>, ["= 0.1.5"])
105
- s.add_dependency(%q<faraday>, ["= 0.7.3"])
106
- s.add_dependency(%q<builder>, [">= 0"])
107
- s.add_dependency(%q<oauth>, [">= 0.4.4"])
108
- s.add_dependency(%q<oauth2>, [">= 0.5.2"])
109
- s.add_dependency(%q<simple_oauth>, [">= 0.1.5"])
110
- s.add_dependency(%q<faraday>, [">= 0.7.3"])
91
+ s.add_dependency(%q<oauth>, ["~> 0.4.4"])
92
+ s.add_dependency(%q<oauth2>, ["~> 0.5.2"])
93
+ s.add_dependency(%q<simple_oauth>, ["~> 0.1.5"])
94
+ s.add_dependency(%q<faraday>, ["~> 0.7.3"])
95
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
111
96
  s.add_dependency(%q<builder>, [">= 0"])
112
97
  end
113
98
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtube_it
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 3
10
- version: 2.1.3
9
+ - 4
10
+ version: 2.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - kylejginavan
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-02-06 00:00:00 -06:00
20
+ date: 2012-02-23 00:00:00 -06:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -25,23 +25,7 @@ dependencies:
25
25
  requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
- - - "="
29
- - !ruby/object:Gem::Version
30
- hash: 49
31
- segments:
32
- - 0
33
- - 8
34
- - 7
35
- version: 0.8.7
36
- name: rake
37
- version_requirements: *id001
38
- prerelease: false
39
- - !ruby/object:Gem::Dependency
40
- type: :runtime
41
- requirement: &id002 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - "="
28
+ - - ~>
45
29
  - !ruby/object:Gem::Version
46
30
  hash: 7
47
31
  segments:
@@ -50,14 +34,14 @@ dependencies:
50
34
  - 4
51
35
  version: 0.4.4
52
36
  name: oauth
53
- version_requirements: *id002
37
+ version_requirements: *id001
54
38
  prerelease: false
55
39
  - !ruby/object:Gem::Dependency
56
40
  type: :runtime
57
- requirement: &id003 !ruby/object:Gem::Requirement
41
+ requirement: &id002 !ruby/object:Gem::Requirement
58
42
  none: false
59
43
  requirements:
60
- - - "="
44
+ - - ~>
61
45
  - !ruby/object:Gem::Version
62
46
  hash: 15
63
47
  segments:
@@ -66,14 +50,14 @@ dependencies:
66
50
  - 2
67
51
  version: 0.5.2
68
52
  name: oauth2
69
- version_requirements: *id003
53
+ version_requirements: *id002
70
54
  prerelease: false
71
55
  - !ruby/object:Gem::Dependency
72
56
  type: :runtime
73
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ requirement: &id003 !ruby/object:Gem::Requirement
74
58
  none: false
75
59
  requirements:
76
- - - "="
60
+ - - ~>
77
61
  - !ruby/object:Gem::Version
78
62
  hash: 17
79
63
  segments:
@@ -82,14 +66,14 @@ dependencies:
82
66
  - 5
83
67
  version: 0.1.5
84
68
  name: simple_oauth
85
- version_requirements: *id004
69
+ version_requirements: *id003
86
70
  prerelease: false
87
71
  - !ruby/object:Gem::Dependency
88
72
  type: :runtime
89
- requirement: &id005 !ruby/object:Gem::Requirement
73
+ requirement: &id004 !ruby/object:Gem::Requirement
90
74
  none: false
91
75
  requirements:
92
- - - "="
76
+ - - ~>
93
77
  - !ruby/object:Gem::Version
94
78
  hash: 5
95
79
  segments:
@@ -98,89 +82,27 @@ dependencies:
98
82
  - 3
99
83
  version: 0.7.3
100
84
  name: faraday
101
- version_requirements: *id005
102
- prerelease: false
103
- - !ruby/object:Gem::Dependency
104
- type: :runtime
105
- requirement: &id006 !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- hash: 3
111
- segments:
112
- - 0
113
- version: "0"
114
- name: builder
115
- version_requirements: *id006
116
- prerelease: false
117
- - !ruby/object:Gem::Dependency
118
- type: :runtime
119
- requirement: &id007 !ruby/object:Gem::Requirement
120
- none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 7
125
- segments:
126
- - 0
127
- - 4
128
- - 4
129
- version: 0.4.4
130
- name: oauth
131
- version_requirements: *id007
132
- prerelease: false
133
- - !ruby/object:Gem::Dependency
134
- type: :runtime
135
- requirement: &id008 !ruby/object:Gem::Requirement
136
- none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- hash: 15
141
- segments:
142
- - 0
143
- - 5
144
- - 2
145
- version: 0.5.2
146
- name: oauth2
147
- version_requirements: *id008
85
+ version_requirements: *id004
148
86
  prerelease: false
149
87
  - !ruby/object:Gem::Dependency
150
88
  type: :runtime
151
- requirement: &id009 !ruby/object:Gem::Requirement
89
+ requirement: &id005 !ruby/object:Gem::Requirement
152
90
  none: false
153
91
  requirements:
154
- - - ">="
92
+ - - ~>
155
93
  - !ruby/object:Gem::Version
156
- hash: 17
94
+ hash: 49
157
95
  segments:
158
- - 0
159
96
  - 1
160
- - 5
161
- version: 0.1.5
162
- name: simple_oauth
163
- version_requirements: *id009
164
- prerelease: false
165
- - !ruby/object:Gem::Dependency
166
- type: :runtime
167
- requirement: &id010 !ruby/object:Gem::Requirement
168
- none: false
169
- requirements:
170
- - - ">="
171
- - !ruby/object:Gem::Version
172
- hash: 5
173
- segments:
174
- - 0
175
- - 7
97
+ - 8
176
98
  - 3
177
- version: 0.7.3
178
- name: faraday
179
- version_requirements: *id010
99
+ version: 1.8.3
100
+ name: jeweler
101
+ version_requirements: *id005
180
102
  prerelease: false
181
103
  - !ruby/object:Gem::Dependency
182
104
  type: :runtime
183
- requirement: &id011 !ruby/object:Gem::Requirement
105
+ requirement: &id006 !ruby/object:Gem::Requirement
184
106
  none: false
185
107
  requirements:
186
108
  - - ">="
@@ -190,7 +112,7 @@ dependencies:
190
112
  - 0
191
113
  version: "0"
192
114
  name: builder
193
- version_requirements: *id011
115
+ version_requirements: *id006
194
116
  prerelease: false
195
117
  description: Upload, delete, update, comment on youtube videos all from one gem.
196
118
  email: kylejginavan@gmail.com