yt 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/yt/collections/base.rb +17 -2
- data/lib/yt/collections/videos.rb +2 -1
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_server_app/videos_spec.rb +15 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1bca9a6106823c8817aef8eb024c9b54ae1a684d
|
4
|
+
data.tar.gz: a4dd91d6a9be61e077ab502b4268cf7362383142
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bcd46f496c2a4cd43a280da1bcea6b54d5527152ed2cf73cae7797ba4eb7033a20f998caf9208d19bc665f9ac9e6ebd2421df48e6f07d4c4171d37414c156f7
|
7
|
+
data.tar.gz: 5da86f76c045a7760ab56ed9022029332c6f2bc75ad2fe10d9750545a0900388f52db27be88e88907e9d893798bd3927de587ce9e5376dbd52eb192104a59ff2
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,17 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
## 0.11.1 - 2014-08-17
|
10
|
+
|
11
|
+
* [ENHANCEMENT] Add Video search even without a parent account or channel
|
12
|
+
|
13
|
+
For instance, to search for the most viewed video on the whole YouTube, run:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
videos = Yt::Collections::Videos.new
|
17
|
+
videos.where(order: 'viewCount').first.title #=> "PSY - GANGNAM STYLE"
|
18
|
+
```
|
19
|
+
|
9
20
|
## 0.11.0 - 2014-08-17
|
10
21
|
|
11
22
|
**How to upgrade**
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
|
|
41
41
|
|
42
42
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
43
43
|
|
44
|
-
gem 'yt', '~> 0.11.
|
44
|
+
gem 'yt', '~> 0.11.1'
|
45
45
|
|
46
46
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
47
47
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
data/lib/yt/collections/base.rb
CHANGED
@@ -19,10 +19,25 @@ module Yt
|
|
19
19
|
new parent: parent, auth: parent.auth
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
# Adds requirements to the collection in order to limit the result of
|
23
|
+
# List methods to only items that match the requirements.
|
24
|
+
#
|
25
|
+
# Under the hood, all the requirements are passed to the YouTube API
|
26
|
+
# as query parameters, after transforming the keys to camel-case.
|
27
|
+
#
|
28
|
+
# To know which requirements are available for each collection, check
|
29
|
+
# the documentation of the corresponding YouTube API endpoint.
|
30
|
+
# For instance the list of valid requirements to filter a list of videos
|
31
|
+
# are at https://developers.google.com/youtube/v3/docs/search/list
|
32
|
+
#
|
33
|
+
# @example Return the first video of a channel (no requirements):
|
34
|
+
# video.channels.first
|
35
|
+
# @example Return the first long video of a channel by video count:
|
36
|
+
# video.channels.where(order: 'viewCount', video_duration: 'long').first
|
37
|
+
def where(requirements = {})
|
23
38
|
self.tap do
|
24
39
|
@items = []
|
25
|
-
@where_params =
|
40
|
+
@where_params = requirements
|
26
41
|
end
|
27
42
|
end
|
28
43
|
|
@@ -48,12 +48,13 @@ module Yt
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def videos_params
|
51
|
-
|
51
|
+
{}.tap do |params|
|
52
52
|
params[:type] = :video
|
53
53
|
params[:max_results] = 50
|
54
54
|
params[:part] = 'snippet'
|
55
55
|
params[:order] = 'date'
|
56
56
|
params[:published_before] = @published_before if @published_before
|
57
|
+
params.merge! @parent.videos_params if @parent
|
57
58
|
apply_where_params! params
|
58
59
|
end
|
59
60
|
end
|
data/lib/yt/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'yt/collections/videos'
|
4
|
+
|
5
|
+
describe Yt::Collections::Videos, :server_app do
|
6
|
+
subject(:videos) { Yt::Collections::Videos.new }
|
7
|
+
|
8
|
+
specify 'without :where conditions, returns all YouTube videos', :ruby2 do
|
9
|
+
expect(videos.size).to be > 100_000
|
10
|
+
end
|
11
|
+
|
12
|
+
specify 'with a query term, only returns some YouTube videos' do
|
13
|
+
expect(videos.where(q: 'Fullscreen CreatorPlatform', video_duration: :long).size).to be < 100_000
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -250,6 +250,7 @@ files:
|
|
250
250
|
- spec/requests/as_server_app/playlist_spec.rb
|
251
251
|
- spec/requests/as_server_app/resource_spec.rb
|
252
252
|
- spec/requests/as_server_app/video_spec.rb
|
253
|
+
- spec/requests/as_server_app/videos_spec.rb
|
253
254
|
- spec/requests/unauthenticated/video_spec.rb
|
254
255
|
- spec/spec_helper.rb
|
255
256
|
- spec/support/fail_matcher.rb
|
@@ -334,6 +335,7 @@ test_files:
|
|
334
335
|
- spec/requests/as_server_app/playlist_spec.rb
|
335
336
|
- spec/requests/as_server_app/resource_spec.rb
|
336
337
|
- spec/requests/as_server_app/video_spec.rb
|
338
|
+
- spec/requests/as_server_app/videos_spec.rb
|
337
339
|
- spec/requests/unauthenticated/video_spec.rb
|
338
340
|
- spec/spec_helper.rb
|
339
341
|
- spec/support/fail_matcher.rb
|