yourub 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/yourub/client.rb +9 -0
- data/lib/yourub/version.rb +1 -1
- data/spec/client_spec.rb +4 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5b25f68cd97cc638719c77656816c17c030dea0
|
4
|
+
data.tar.gz: 3fdd04b6f733c71736b1c50ef489b656c87b7c6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/yourub/version.rb
CHANGED
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
|