yourub 1.0.10 → 1.0.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a4c6a883b4aabec736c7dfdbd564930455070bd
4
- data.tar.gz: 400abbb415acc47fcd28723e4a4a5fd9e8bec9cd
3
+ metadata.gz: e5b25f68cd97cc638719c77656816c17c030dea0
4
+ data.tar.gz: 3fdd04b6f733c71736b1c50ef489b656c87b7c6b
5
5
  SHA512:
6
- metadata.gz: d1025ebe899c9f2b6a71a22b368fca7846750855b4cd58a71aff84cbe97384b96d73fc2bc9e73292021d5f610f2cb1ef5f7ac593acbbe996315f0ccef439dae1
7
- data.tar.gz: 7de65afde81961d9ccd23186e921feda72dbba3fd74a244e70f62d672c10cd1779ced46f8eeb0b2cb3c88a382ad12224d45aa974bbf854a45edaf709dda64182
6
+ metadata.gz: 3c4bda324352e9db0ab4a0f4ab310bcbad4eed52ef5063f7f4dfac8d8544cd7a1ade065b46871cfb60f0af885e9f7e5eca735bd68a8a7746b86bd0b4f0c89003
7
+ data.tar.gz: c88d7465826fb9f1d13934f693d4257608e7d78204d3112e0517095fbf55237138fee7c3f515a2eb718993804ff896a67c5ba0f4a7ca1021d003caf600d21de7
data/README.md CHANGED
@@ -97,6 +97,12 @@ It will give you much more information
97
97
  [{"kind"=>"youtube#video", "etag"=>"\"N5Eg36Gl054SUNiWWc-Su3t5O-k/U6AzLXvcnZt2WFqpnq9_dksV7DA\"", "id"=>"NisCkxU544c", "snippet"=>{"publishedAt"=>"2009-04-05T05:20:10.000Z", "channelId"=>"UCCHcEUksSVKsRDH86j77Ntg", "title"=>"Like A Boss (ft. Seth Rogen) - Uncensored Version", "description"=>"http://www.itunes.com/thelonelyisland\r\n\r\nThe new single from The Lonely Island's debut album \"INCREDIBAD\" In stores now!\r\n\r\nFeaturing Seth Rogen.\r\n\r\nThe Lonely Island is Andy Samberg, Akiva Schaffer & Jorma Taccone.", "thumbnails"=>{"default"=>{"url"=>"https://i1.ytimg.com/vi/NisCkxU544c/default.jpg", "width"=>120, "height"=>90}, "medium"=>{"url"=>"https://i1.ytimg.com/vi/NisCkxU544c/mqdefault.jpg", "width"=>320, "height"=>180}, "high"=>{"url"=>"https://i1.ytimg.com/vi/NisCkxU544c/hqdefault.jpg", "width"=>480, "height"=>360}, "standard"=>{"url"=>"https://i1.ytimg.com/vi/NisCkxU544c/sddefault.jpg", "width"=>640, "height"=>480}, "maxres"=>{"url"=>"https://i1.ytimg.com/vi/NisCkxU544c/maxresdefault.jpg", "width"=>1280, "height"=>720}}, "channelTitle"=>"thelonelyisland", "categoryId"=>"23", "liveBroadcastContent"=>"none"}, "statistics"=>{"viewCount"=>"120176425", "likeCount"=>"594592", "dislikeCount"=>"15121", "favoriteCount"=>"0", "commentCount"=>"208109"}}]
98
98
  ```
99
99
 
100
+ To simply get the number of views for a given video, use `get_views`
101
+ ```ruby
102
+ client = Yourub::Client.new
103
+ client.get_views("G2b0OIkTraI")
104
+ ```
105
+
100
106
  ##TODO
101
107
 
102
108
  1. adding a CLI
data/lib/yourub/client.rb CHANGED
@@ -189,5 +189,14 @@ module Yourub
189
189
  return name.gsub("/", "-").downcase.gsub(/\s+/, "")
190
190
  end
191
191
 
192
+ def get_views(id)
193
+ request = client.execute!(
194
+ :api_method => youtube.videos.list,
195
+ :parameters => {:id => id, :part => 'statistics'}
196
+ )
197
+ v = Yourub::Reader.parse_videos(request)
198
+ v ? Yourub::CountFilter.get_views_count(v.first) : nil
199
+ end
200
+
192
201
  end
193
202
  end
@@ -1,6 +1,6 @@
1
1
  module Yourub
2
2
  MAJOR = 1
3
3
  MINOR = 0
4
- PATCH = 10
4
+ PATCH = 11
5
5
  VERSION = [MAJOR, MINOR, PATCH].compact.join('.')
6
6
  end
data/spec/client_spec.rb CHANGED
@@ -67,6 +67,10 @@ describe Yourub::Client do
67
67
  expect(subject.videos.first["id"]).to eql("mN0Dbj-xHY0")
68
68
  end
69
69
 
70
+ it "retrieves the view count for given id" do
71
+ expect(subject.get_views("mN0Dbj-xHY0")).to be_a_kind_of(Integer)
72
+ end
73
+
70
74
  it "return nil for a not existing video" do
71
75
  subject.search(id: "fffffffffffffffffffff")
72
76
  expect(subject.videos).to be_empty
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yourub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Davide Prati