yt 0.11.4 → 0.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/yt/collections/videos.rb +12 -8
- data/lib/yt/models/video.rb +3 -1
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_server_app/videos_spec.rb +6 -2
- 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: 42014f27313df641d183c3372c321750d4286503
|
4
|
+
data.tar.gz: fdfcb6df1b63ed5943f50292111c43279c3e8cbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb5e31dcea230569c121333be4829eb24c964224c88e60ba506fbbe7aadc2aae4019be292a944135da2b07e0fa89d2e36306adcc5f853685d4d0c83612901163
|
7
|
+
data.tar.gz: 34df50c4d27f24824605e49e8a9305b8efdbe290b94aab35f31ff5f254f979ed5edac78ec266fdae61ebec4a0333226882e6185ec68443f1206c60db0eb41db2
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ 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.5 - 2014-08-27
|
10
|
+
|
11
|
+
* [BUGFIX] Make videos.where(id: 'MESycYJytkU').first.id return 'MESycYJytkU'
|
12
|
+
|
9
13
|
## 0.11.4 - 2014-08-27
|
10
14
|
|
11
15
|
* [ENHANCEMENT] Add Video search even by id, chart or rating
|
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.5'
|
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*)
|
@@ -12,8 +12,9 @@ module Yt
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def attributes_for_new_item(data)
|
15
|
+
id = use_list_endpoint? ? data['id'] : data['id']['videoId']
|
15
16
|
snippet = data.fetch('snippet', {}).merge includes_tags: false
|
16
|
-
{id:
|
17
|
+
{id: id, snippet: snippet, auth: @auth}
|
17
18
|
end
|
18
19
|
|
19
20
|
# @return [Hash] the parameters to submit to YouTube to list videos.
|
@@ -52,17 +53,20 @@ module Yt
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
56
|
+
def videos_path
|
57
|
+
use_list_endpoint? ? '/youtube/v3/videos' : '/youtube/v3/search'
|
58
|
+
end
|
59
|
+
|
55
60
|
# @private
|
61
|
+
# YouTube API provides two different endpoints to get a list of videos:
|
62
|
+
# /videos should be used when the query specifies video IDs or a chart,
|
63
|
+
# /search otherwise.
|
64
|
+
# @return [Boolean] whether to use the /videos endpoint.
|
56
65
|
# @todo: This is one of two places outside of base.rb where @where_params
|
57
66
|
# is accessed; it should be replaced with a filter on params instead.
|
58
|
-
|
59
|
-
def videos_path
|
67
|
+
def use_list_endpoint?
|
60
68
|
@where_params ||= {}
|
61
|
-
|
62
|
-
'/youtube/v3/videos'
|
63
|
-
else
|
64
|
-
'/youtube/v3/search'
|
65
|
-
end
|
69
|
+
@parent.nil? && (@where_params.keys & [:id, :chart]).any?
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
data/lib/yt/models/video.rb
CHANGED
@@ -76,7 +76,9 @@ module Yt
|
|
76
76
|
# @return [Array<Yt::Models::Tag>] the list of keyword tags associated
|
77
77
|
# with the video.
|
78
78
|
def tags
|
79
|
-
|
79
|
+
unless snippet.tags.any? || snippet.includes_tags || @auth.nil?
|
80
|
+
@snippet = nil
|
81
|
+
end
|
80
82
|
snippet.tags
|
81
83
|
end
|
82
84
|
|
data/lib/yt/version.rb
CHANGED
@@ -13,8 +13,12 @@ describe Yt::Collections::Videos, :server_app do
|
|
13
13
|
expect(videos.where(q: 'Fullscreen CreatorPlatform', video_duration: :long).size).to be < 100_000
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
context 'with a list of video IDs, only returns the videos matching those IDs' do
|
17
|
+
let(:video_id) { 'MESycYJytkU' }
|
18
|
+
let(:videos_by_id) { videos.where id: "#{video_id},invalid" }
|
19
|
+
|
20
|
+
it { expect(videos_by_id.size).to be 1 }
|
21
|
+
it { expect(videos_by_id.first.id).to eq video_id }
|
18
22
|
end
|
19
23
|
|
20
24
|
specify 'with a chart parameter, only returns videos of that chart', :ruby2 do
|