yt 0.25.10 → 0.25.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/yt/collections/playlists.rb +24 -0
- data/lib/yt/models/playlist.rb +10 -0
- data/lib/yt/models/url.rb +1 -0
- data/lib/yt/version.rb +1 -1
- data/spec/models/url_spec.rb +6 -0
- data/spec/requests/as_account/channel_spec.rb +10 -0
- 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: e038a6da2ec69b1130e124d8c436a178a601cf4f
|
|
4
|
+
data.tar.gz: fd7c52d0cc6cfc3fa789d68cb99e4cce88338e9a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2daaf03e57761920bafac958fb3b240efea2febdb84383c494c0629ccd7f669c01ec0cb062b52ec89e398628acaa7f661383d73386e684f53b2242ed9d200e70
|
|
7
|
+
data.tar.gz: 2488a4f82a7598c4abffe422a8ec2d4d97f550700b4de787b1482b008baaef2542ebdd799831e070ba9d10c4a4696d0d48e364a3dffe4d4b68f1dcd8ef8599dc
|
data/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,11 @@ 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.25.11 - 2015-11-05
|
|
10
|
+
|
|
11
|
+
* [ENHANCEMENT] Add "youtube.com/v/..." as possible URL for YouTube videos
|
|
12
|
+
* [ENHANCEMENT] Add eager loading to channel.playlists
|
|
13
|
+
|
|
9
14
|
## 0.25.10 - 2015-10-29
|
|
10
15
|
|
|
11
16
|
* [FEATURE] Add Playlist#item_count
|
|
@@ -18,6 +18,30 @@ module Yt
|
|
|
18
18
|
apply_where_params! params
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def attributes_for_new_item(data)
|
|
22
|
+
super.merge content_details: data['contentDetails']
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def eager_load_items_from(items)
|
|
26
|
+
if included_relationships.any?
|
|
27
|
+
ids = items.map{|item| item['id']}
|
|
28
|
+
parts = included_relationships.map{|r| r.to_s.camelize(:lower)}
|
|
29
|
+
conditions = {id: ids.join(','), part: parts.join(',')}
|
|
30
|
+
playlists = Collections::Playlists.new(auth: @auth).where conditions
|
|
31
|
+
|
|
32
|
+
items.each do |item|
|
|
33
|
+
playlist = playlists.find{|playlist| playlist.id == item['id']}
|
|
34
|
+
parts.each do |part|
|
|
35
|
+
item[part] = case part
|
|
36
|
+
when 'snippet' then playlist.snippet.data.merge complete: true
|
|
37
|
+
when 'contentDetails' then playlist.content_detail.data
|
|
38
|
+
end
|
|
39
|
+
end if playlist
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
super
|
|
43
|
+
end
|
|
44
|
+
|
|
21
45
|
def insert_parts
|
|
22
46
|
snippet = {keys: [:title, :description, :tags], sanitize_brackets: true}
|
|
23
47
|
status = {keys: [:privacy_status]}
|
data/lib/yt/models/playlist.rb
CHANGED
|
@@ -184,6 +184,16 @@ module Yt
|
|
|
184
184
|
|
|
185
185
|
### PRIVATE API ###
|
|
186
186
|
|
|
187
|
+
# @private
|
|
188
|
+
# Override Resource's new to set content details as well
|
|
189
|
+
# if the response includes them
|
|
190
|
+
def initialize(options = {})
|
|
191
|
+
super options
|
|
192
|
+
if options[:content_details]
|
|
193
|
+
@content_detail = ContentDetail.new data: options[:content_details]
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
187
197
|
# @private
|
|
188
198
|
# Tells `has_reports` to retrieve the reports from YouTube Analytics API
|
|
189
199
|
# either as a Channel or as a Content Owner.
|
data/lib/yt/models/url.rb
CHANGED
data/lib/yt/version.rb
CHANGED
data/spec/models/url_spec.rb
CHANGED
|
@@ -25,6 +25,12 @@ describe Yt::URL do
|
|
|
25
25
|
it {expect(url.id).to eq 'MESycYJytkU' }
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
context 'given a v video URL' do
|
|
29
|
+
let(:text) { 'https://www.youtube.com/v/MESycYJytkU' }
|
|
30
|
+
it {expect(url.kind).to eq :video }
|
|
31
|
+
it {expect(url.id).to eq 'MESycYJytkU' }
|
|
32
|
+
end
|
|
33
|
+
|
|
28
34
|
context 'given a playlist-embedded video URL' do
|
|
29
35
|
let(:text) { 'youtube.com/watch?v=MESycYJytkU&list=LLxO1tY8h1AhOz0T4ENwmpow' }
|
|
30
36
|
it {expect(url.kind).to eq :video }
|
|
@@ -99,6 +99,16 @@ describe Yt::Channel, :device_app do
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
+
describe '.playlists' do
|
|
103
|
+
describe '.includes(:content_details)' do
|
|
104
|
+
let(:playlist) { channel.playlists.includes(:content_details).first }
|
|
105
|
+
|
|
106
|
+
specify 'eager-loads the content details of each playlist' do
|
|
107
|
+
expect(playlist.instance_variable_defined? :@content_detail).to be true
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
102
112
|
it { expect(channel.playlists.first).to be_a Yt::Playlist }
|
|
103
113
|
it { expect{channel.delete_playlists}.to raise_error Yt::Errors::RequestError }
|
|
104
114
|
|
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.25.
|
|
4
|
+
version: 0.25.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Claudio Baccigalupo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-11-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|