yt 0.13.4 → 0.13.5
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 +4 -0
- data/README.md +4 -0
- data/lib/yt/collections/advertising_options_sets.rb +34 -0
- data/lib/yt/models/advertising_options_set.rb +11 -1
- data/lib/yt/models/video.rb +3 -0
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_account/video_spec.rb +1 -0
- data/spec/requests/as_content_owner/ownership_spec.rb +2 -0
- data/spec/requests/as_content_owner/video_spec.rb +16 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4884014eca0d0aa5a8fce33dd4aab23a10be20c7
|
4
|
+
data.tar.gz: aa69ac27584d778a2c6d737eef6423cd7fc918c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f0a0e1d935a0a6458d424e0777cdb8293ea52b750e3a95833930deb10f4dbc4ec2a5aa6dd51b93f2bf97b9772cf9d3bf635384d3b8b0775f66123d725036c7d
|
7
|
+
data.tar.gz: 5356a175d23cfa1e4e6404ae83fdde6aa5a70f88f9f63c8411363a57c7ab347e7379b30104221b8c38b5690e3f68802213b33e73fa96615afb09704c294ad3f8
|
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.13.5 - 2014-10-06
|
10
|
+
|
11
|
+
* [ENHANCEMENT] Add `advertising_options_set` and `ad_formats` to video
|
12
|
+
|
9
13
|
## 0.13.4 - 2014-10-01
|
10
14
|
|
11
15
|
* [ENHANCEMENT] Accept `policy` (with custom set of rules) in `content_owner.create_claim`
|
data/README.md
CHANGED
@@ -239,6 +239,7 @@ Use [Yt::Video](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Video)
|
|
239
239
|
* retrieve the daily earnings, views, comments, likes, dislikes, shares and impressions of a video
|
240
240
|
* retrieve the viewer percentage of a video by gender and age group
|
241
241
|
* retrieve data about live-streaming videos
|
242
|
+
* retrieve the advertising options of a video
|
242
243
|
|
243
244
|
```ruby
|
244
245
|
# Videos can be initialized with ID or URL
|
@@ -345,6 +346,8 @@ video.impressions_on 5.days.ago #=> 157.0
|
|
345
346
|
|
346
347
|
video.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}…}
|
347
348
|
video.viewer_percentage(gender: :female) #=> 49.12
|
349
|
+
|
350
|
+
video.ad_formats #=> ["standard_instream", "trueview_instream"]
|
348
351
|
```
|
349
352
|
|
350
353
|
*The methods above require to be authenticated as the video’s content owner (see below).*
|
@@ -490,6 +493,7 @@ asset.ownership #=> #<Yt::Models::Ownership @general=...>
|
|
490
493
|
asset.ownership.obtain! #=> true
|
491
494
|
asset.general_owners.first.owner #=> 'CMSname'
|
492
495
|
asset.general_owners.first.everywhere? #=> true
|
496
|
+
asset.ownership.release! #=> true
|
493
497
|
|
494
498
|
asset.update metadata_mine: {notes: 'Some notes'} #=> true
|
495
499
|
```
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'yt/collections/resources'
|
2
|
+
require 'yt/models/advertising_options_set'
|
3
|
+
|
4
|
+
module Yt
|
5
|
+
module Collections
|
6
|
+
# Provides methods to interact with a the advertising options of a YouTube video.
|
7
|
+
#
|
8
|
+
# Resources with advertising options are: {Yt::Models::Video videos}.
|
9
|
+
class AdvertisingOptionsSets < Resources
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def attributes_for_new_item(data)
|
14
|
+
{data: data, video_id: @parent.id, auth: @auth}
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Hash] the parameters to submit to YouTube to get video advertising options.
|
18
|
+
# @see https://developers.google.com/youtube/partner/docs/v1/videoAdvertisingOptions/get
|
19
|
+
def list_params
|
20
|
+
super.tap do |params|
|
21
|
+
params[:path] = "/youtube/partner/v1/videoAdvertisingOptions/#{@parent.id}"
|
22
|
+
params[:params] = {on_behalf_of_content_owner: @auth.owner_name}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @private
|
27
|
+
# @note AdvertisingOptionsSets overwrites +fetch_page+ since it’s a get.
|
28
|
+
def fetch_page(params = {})
|
29
|
+
response = list_request(params).run
|
30
|
+
{items: [response.body], token: nil}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -10,14 +10,24 @@ module Yt
|
|
10
10
|
def initialize(options = {})
|
11
11
|
@auth = options[:auth]
|
12
12
|
@video_id = options[:video_id]
|
13
|
+
@data = options[:data]
|
13
14
|
end
|
14
15
|
|
15
16
|
def update(attributes = {})
|
16
17
|
underscore_keys! attributes
|
17
|
-
do_patch
|
18
|
+
do_patch(body: attributes) {|data| @data = data}
|
18
19
|
true
|
19
20
|
end
|
20
21
|
|
22
|
+
# Return the list of ad formats that the video is allowed to show.
|
23
|
+
# Valid values for this property are: long, overlay, standard_instream,
|
24
|
+
# third_party, trueview_inslate, or trueview_instream.
|
25
|
+
# @return [Array<String>] the list of ad formats that the video is
|
26
|
+
# allowed to show.
|
27
|
+
def ad_formats
|
28
|
+
@data['adFormats']
|
29
|
+
end
|
30
|
+
|
21
31
|
private
|
22
32
|
|
23
33
|
# @see https://developers.google.com/youtube/partner/docs/v1/videoAdvertisingOptions/patch
|
data/lib/yt/models/video.rb
CHANGED
@@ -23,6 +23,9 @@ module Yt
|
|
23
23
|
delegate :duration, :hd?, :stereoscopic?, :captioned?, :licensed?,
|
24
24
|
to: :content_detail
|
25
25
|
|
26
|
+
has_one :advertising_options_set
|
27
|
+
delegate :ad_formats, to: :advertising_options_set
|
28
|
+
|
26
29
|
# @!attribute [r] rating
|
27
30
|
# @return [Yt::Models::Rating] the video’s rating.
|
28
31
|
has_one :rating
|
data/lib/yt/version.rb
CHANGED
@@ -305,6 +305,7 @@ describe Yt::Video, :device_app do
|
|
305
305
|
expect{video.shares}.not_to raise_error
|
306
306
|
expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
|
307
307
|
expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
|
308
|
+
expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
|
308
309
|
|
309
310
|
expect{video.views_on 3.days.ago}.not_to raise_error
|
310
311
|
expect{video.comments_on 3.days.ago}.not_to raise_error
|
@@ -13,10 +13,12 @@ describe Yt::Ownership, :partner do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe 'the complete ownership can be obtained' do
|
16
|
+
before { ownership.release! }
|
16
17
|
it { expect(ownership.obtain!).to be true }
|
17
18
|
end
|
18
19
|
|
19
20
|
describe 'the complete ownership can be released' do
|
21
|
+
after { ownership.obtain! }
|
20
22
|
it { expect(ownership.release!).to be true }
|
21
23
|
end
|
22
24
|
end
|
@@ -9,6 +9,10 @@ describe Yt::Video, :partner do
|
|
9
9
|
context 'managed by the authenticated Content Owner' do
|
10
10
|
let(:id) { ENV['YT_TEST_VIDEO_CHANNEL_ID'] }
|
11
11
|
|
12
|
+
describe 'advertising options can be retrieved' do
|
13
|
+
it { expect{video.advertising_options_set}.not_to raise_error }
|
14
|
+
end
|
15
|
+
|
12
16
|
describe 'earnings can be retrieved for a specific day' do
|
13
17
|
context 'in which the video made any money' do
|
14
18
|
let(:earnings) {video.earnings_on 5.days.ago}
|
@@ -251,5 +255,17 @@ describe Yt::Video, :partner do
|
|
251
255
|
expect(video.viewer_percentage(gender: :female)).to be_a Float
|
252
256
|
end
|
253
257
|
end
|
258
|
+
|
259
|
+
context 'given a video claimable by the authenticated Content Owner' do
|
260
|
+
let(:id) { ENV['YT_TEST_PARTNER_CLAIMABLE_VIDEO_ID'] }
|
261
|
+
|
262
|
+
describe 'the advertising formats can be updated and retrieved' do
|
263
|
+
let!(:old_formats) { video.ad_formats }
|
264
|
+
let!(:new_formats) { %w(standard_instream overlay trueview_instream).sample(2) }
|
265
|
+
before { video.advertising_options_set.update ad_formats: new_formats }
|
266
|
+
it { expect(video.ad_formats).to match_array new_formats }
|
267
|
+
after { video.advertising_options_set.update ad_formats: old_formats }
|
268
|
+
end
|
269
|
+
end
|
254
270
|
end
|
255
271
|
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.13.
|
4
|
+
version: 0.13.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/yt/associations/has_one.rb
|
131
131
|
- lib/yt/associations/has_reports.rb
|
132
132
|
- lib/yt/associations/has_viewer_percentages.rb
|
133
|
+
- lib/yt/collections/advertising_options_sets.rb
|
133
134
|
- lib/yt/collections/annotations.rb
|
134
135
|
- lib/yt/collections/assets.rb
|
135
136
|
- lib/yt/collections/authentications.rb
|