yt 0.7.8 → 0.7.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e5cc6f7948f9df0ff8bb425aa5ed45cb653a810
4
- data.tar.gz: 5e150be0550652202b54315ba399fb7c3ad02404
3
+ metadata.gz: cfcbde361ff972549cb68415dd88749f21c517e0
4
+ data.tar.gz: 1c1f419d4bb67484a0d00e2cb0b710cfdcc63c18
5
5
  SHA512:
6
- metadata.gz: adb48260492477a302919bea67fa73291403cf48532297bdd3f80392c3da01e0f49c8d022064c82612ceb6af528728607390bb791a75b1d165b8dd08c822a2c9
7
- data.tar.gz: 143a4e311f40230fa56c17d76edb9eff0192d5c809abf011881a084f4d7ebb03abc5b8e95bf88771cfac47c322c5db998a199d4db2a7ce3e550bcf9f922bd8c5
6
+ metadata.gz: 6b02f9e1d4354bc4a5fb3cb5b66b5f212a7cecc2284f7f472dcf56006bccc257466d20008250a062473b529f36f4f00575a7af28adfa2bd2b53ddd77c3c15c38
7
+ data.tar.gz: b684f9e3660801b5452e8629a76a308321f02ee75fe54ea80ddc4a0cf0734dfa39bca1a485d82077a171591840abb700b6b93501005217ec035c77e49a52495b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.7.8)
4
+ yt (0.7.9)
5
5
  activesupport
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -15,6 +15,7 @@ v0.7 - 2014/06/18
15
15
  * Allow both normal and partnered channels to retrieve reports about views, comments, likes, dislikes, shares
16
16
  * Make reports available also on Video (not just Channel)
17
17
  * New account.upload_video to upload a video (either local or remote).
18
+ * Make channel.videos access more than 500 videos per channel
18
19
 
19
20
  v0.6 - 2014/06/05
20
21
  -----------------
data/README.md CHANGED
@@ -32,6 +32,22 @@ video.annotations.count #=> 1
32
32
 
33
33
  The **full documentation** is available at [rubydoc.info](http://rubydoc.info/github/Fullscreen/yt/master/frames).
34
34
 
35
+ How to install
36
+ ==============
37
+
38
+ To install on your system, run
39
+
40
+ gem install yt
41
+
42
+ To use inside a bundled Ruby project, add this line to the Gemfile:
43
+
44
+ gem 'yt', '~> 0.7.9'
45
+
46
+ Since the gem follows [Semantic Versioning](http://semver.org),
47
+ indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
48
+ guarantees that your project won’t occur in any error when you `bundle update`
49
+ and a new version of Yt is released.
50
+
35
51
  Available resources
36
52
  ===================
37
53
 
@@ -466,24 +482,8 @@ end
466
482
  so use the approach that you prefer.
467
483
  If a variable is set in both places, then `Yt.configure` takes precedence.
468
484
 
469
- How to install
470
- ==============
471
-
472
- To install on your system, run
473
-
474
- gem install yt
475
-
476
- To use inside a bundled Ruby project, add this line to the Gemfile:
477
-
478
- gem 'yt', '~> 0.7.8'
479
-
480
- Since the gem follows [Semantic Versioning](http://semver.org),
481
- indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
482
- guarantees that your project won’t occur in any error when you `bundle update`
483
- and a new version of Yt is released.
484
-
485
485
  Why you should use Yt…
486
- -----------------------
486
+ ======================
487
487
 
488
488
  … and not [youtube_it](https://github.com/kylejginavan/youtube_it)?
489
489
  Because youtube_it does not support Google API V3 and the previous version
@@ -27,8 +27,24 @@ module Yt
27
27
  end
28
28
  end
29
29
 
30
+ def next_page
31
+ super.tap{|items| add_offset_to(items) if @page_token.nil?}
32
+ end
33
+
34
+ # According to http://stackoverflow.com/a/23256768 YouTube does not
35
+ # provide more than 500 results for any query. In order to overcome
36
+ # that limit, the query is restarted with a publishedBefore filter in
37
+ # case there are more videos to be listed for a channel
38
+ def add_offset_to(items)
39
+ if items.count == videos_params[:maxResults]
40
+ last_published = items.last['snippet']['publishedAt']
41
+ @page_token, @published_before = '', last_published
42
+ end
43
+ end
44
+
30
45
  def videos_params
31
46
  params = {type: :video, maxResults: 50, part: 'snippet', order: 'date'}
47
+ params[:publishedBefore] = @published_before if @published_before
32
48
  @extra_params ||= {}
33
49
  params.merge @extra_params
34
50
  end
@@ -48,7 +48,7 @@ module Yt
48
48
  @response ||= Net::HTTP.start(*net_http_options) do |http|
49
49
  http.request http_request
50
50
  end
51
- rescue OpenSSL::SSL::SSLError, Errno::ETIMEDOUT, Errno::ENETUNREACH => e
51
+ rescue OpenSSL::SSL::SSLError, Errno::ETIMEDOUT, Errno::ENETUNREACH, Errno::ECONNRESET => e
52
52
  @response ||= e
53
53
  end
54
54
 
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.7.8'
2
+ VERSION = '0.7.9'
3
3
  end
@@ -40,6 +40,15 @@ describe Yt::Channel, :device_app do
40
40
  it { expect(channel.subscribed?).to be true }
41
41
  it { expect(channel.unsubscribe!).to be_truthy }
42
42
  end
43
+
44
+ # NOTE: These tests are slow because they go through multiple pages of
45
+ # results and do so to test that we can overcome YouTube’s limitation of
46
+ # only returning the first 500 results for each query.
47
+ context 'with more than 500 videos' do
48
+ let(:id) { 'UCsmvakQZlvGsyjyOhmhvOsw' }
49
+ it { expect(channel.video_count).to be > 500 }
50
+ it { expect(channel.videos.count).to be > 500 }
51
+ end
43
52
  end
44
53
 
45
54
  context 'given my own channel' do
@@ -216,7 +216,7 @@ describe Yt::Channel, :partner do
216
216
 
217
217
  describe 'impressions can be retrieved for a specific day' do
218
218
  context 'in which the channel was partnered' do
219
- let(:impressions) { channel.impressions_on 5.days.ago}
219
+ let(:impressions) { channel.impressions_on 20.days.ago}
220
220
  it { expect(impressions).to be_a Float }
221
221
  end
222
222
 
@@ -203,7 +203,7 @@ describe Yt::Video, :partner do
203
203
 
204
204
  describe 'impressions can be retrieved for a specific day' do
205
205
  context 'in which the video was partnered' do
206
- let(:impressions) { video.impressions_on 5.days.ago}
206
+ let(:impressions) { video.impressions_on 20.days.ago}
207
207
  it { expect(impressions).to be_a Float }
208
208
  end
209
209
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-03 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport