yt 0.7.8 → 0.7.9
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/HISTORY.md +1 -0
- data/README.md +17 -17
- data/lib/yt/collections/videos.rb +16 -0
- data/lib/yt/models/request.rb +1 -1
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_account/channel_spec.rb +9 -0
- data/spec/requests/as_content_owner/channel_spec.rb +1 -1
- data/spec/requests/as_content_owner/video_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfcbde361ff972549cb68415dd88749f21c517e0
|
4
|
+
data.tar.gz: 1c1f419d4bb67484a0d00e2cb0b710cfdcc63c18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b02f9e1d4354bc4a5fb3cb5b66b5f212a7cecc2284f7f472dcf56006bccc257466d20008250a062473b529f36f4f00575a7af28adfa2bd2b53ddd77c3c15c38
|
7
|
+
data.tar.gz: b684f9e3660801b5452e8629a76a308321f02ee75fe54ea80ddc4a0cf0734dfa39bca1a485d82077a171591840abb700b6b93501005217ec035c77e49a52495b
|
data/Gemfile.lock
CHANGED
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
|
data/lib/yt/models/request.rb
CHANGED
@@ -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
|
|
data/lib/yt/version.rb
CHANGED
@@ -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
|
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
|
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.
|
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-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|