yt 0.15.1 → 0.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/README.md +4 -1
- data/lib/yt.rb +1 -0
- data/lib/yt/collections/assets.rb +1 -3
- data/lib/yt/collections/players.rb +29 -0
- data/lib/yt/models/player.rb +19 -0
- data/lib/yt/models/video.rb +5 -0
- data/lib/yt/version.rb +1 -1
- data/spec/models/player_spec.rb +21 -0
- data/spec/requests/as_account/video_spec.rb +1 -0
- data/spec/requests/as_content_owner/content_owner_spec.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe92325f41cffdb8e81da539742c539cc3280fd0
|
4
|
+
data.tar.gz: 40ccb712b549661f2cd905dfed5870cf14d77f4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2567686bcaae799d503506e063ec171e16fa7ed975e9fb78d053c971c1aad144c0d3bdabc10daf7ad69b30045ef8c8edb945c37d0b19ed007cb5d664b774e9c4
|
7
|
+
data.tar.gz: 6283dfcb5b3288c2bf1f66bd15833a5bd073982f253b759c3fceb665c6c29ce7e373073aa0a9e1243b82167e5b58f9e7d1ae8f02f90a2764ac77289279398e0c
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,10 @@ For more information about changelogs, check
|
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
9
|
|
10
|
+
## 0.15.2 - 2015-04-27
|
11
|
+
|
12
|
+
* [FEATURE] New `embed_html` method for Yt::Video.
|
13
|
+
|
10
14
|
## 0.15.1 - 2015-04-19
|
11
15
|
|
12
16
|
* [FEATURE] New `annotation clicks` report for videos and channels.
|
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.15.
|
44
|
+
gem 'yt', '~> 0.15.2'
|
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*)
|
@@ -309,6 +309,7 @@ Use [Yt::Video](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Video)
|
|
309
309
|
* retrieve the viewer percentage of a video by gender, by age group or by both
|
310
310
|
* retrieve data about live-streaming videos
|
311
311
|
* retrieve the advertising options of a video
|
312
|
+
* retrieve the HTML code of the video player
|
312
313
|
|
313
314
|
```ruby
|
314
315
|
# Videos can be initialized with ID or URL
|
@@ -365,6 +366,8 @@ video.scheduled_start_time #=> Tue, 27 May 2014 12:49:00
|
|
365
366
|
video.scheduled_end_time #=> Tue, 27 May 2014 12:55:00
|
366
367
|
video.concurrent_viewers #=> 0
|
367
368
|
|
369
|
+
video.embed_html #=> "<iframe type='text/html' src='http://www.youtube.com/embed/BPNYv0vd78A' width='640' height='360' frameborder='0' allowfullscreen='true'/>"
|
370
|
+
|
368
371
|
video.annotations.count #=> 1
|
369
372
|
video.annotations.first #=> #<Yt::Models::Annotation @id=...>
|
370
373
|
```
|
data/lib/yt.rb
CHANGED
@@ -9,10 +9,8 @@ module Yt
|
|
9
9
|
# Resources with assets are: {Yt::Models::ContentOwner content owners}.
|
10
10
|
class Assets < Base
|
11
11
|
def insert(attributes = {})
|
12
|
-
underscore_keys! attributes
|
13
|
-
body = {type: attributes[:type]}
|
14
12
|
params = {on_behalf_of_content_owner: @auth.owner_name}
|
15
|
-
do_insert(params: params, body:
|
13
|
+
do_insert(params: params, body: attributes)
|
16
14
|
end
|
17
15
|
|
18
16
|
private
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'yt/collections/base'
|
2
|
+
require 'yt/models/player'
|
3
|
+
|
4
|
+
module Yt
|
5
|
+
module Collections
|
6
|
+
class Players < Base
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def attributes_for_new_item(data)
|
11
|
+
{data: data['player']}
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [Hash] the parameters to submit to YouTube to get the
|
15
|
+
# statistics of a resource, for instance a video.
|
16
|
+
# @see https://developers.google.com/youtube/v3/docs/videos#resource
|
17
|
+
def list_params
|
18
|
+
super.tap do |params|
|
19
|
+
params[:path] = "/youtube/v3/#{@parent.kind.pluralize}"
|
20
|
+
params[:params] = players_params
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def players_params
|
25
|
+
{max_results: 50, part: 'player', id: @parent.id}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'yt/models/base'
|
2
|
+
|
3
|
+
module Yt
|
4
|
+
module Models
|
5
|
+
# Encapsulates information about a video player.
|
6
|
+
# @see https://developers.google.com/youtube/v3/docs/videos#player
|
7
|
+
class Player < Base
|
8
|
+
attr_reader :data
|
9
|
+
|
10
|
+
def initialize(options = {})
|
11
|
+
@data = options[:data]
|
12
|
+
end
|
13
|
+
|
14
|
+
# @return [String] the HTML code of an <iframe> tag that embeds a
|
15
|
+
# player that will play the video.
|
16
|
+
has_attribute :embed_html
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/yt/models/video.rb
CHANGED
@@ -111,6 +111,11 @@ module Yt
|
|
111
111
|
delegate :view_count, :like_count, :dislike_count, :favorite_count,
|
112
112
|
:comment_count, to: :statistics_set
|
113
113
|
|
114
|
+
# @!attribute [r] player
|
115
|
+
# @return [Yt::Models::Player] the player for the video.
|
116
|
+
has_one :player
|
117
|
+
delegate :embed_html, to: :player
|
118
|
+
|
114
119
|
# @!attribute [r] resumable_sessions
|
115
120
|
# @return [Yt::Collections::ResumableSessions] the sessions used to
|
116
121
|
# upload thumbnails using the resumable upload protocol.
|
data/lib/yt/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yt/models/player'
|
3
|
+
|
4
|
+
describe Yt::Player do
|
5
|
+
subject(:player) { Yt::Player.new data: data }
|
6
|
+
let(:value) { "<iframe type='text/html' src='http://www.youtube.com/embed/BPNYv0vd78A' width='640' height='360' frameborder='0' allowfullscreen='true'/>" }
|
7
|
+
|
8
|
+
describe '#data' do
|
9
|
+
let(:data) { {"key"=>"value"} }
|
10
|
+
specify 'returns the data the statistics set was initialized with' do
|
11
|
+
expect(player.data).to eq data
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#embed_html' do
|
16
|
+
context 'given a video with embedHtml' do
|
17
|
+
let(:data) { {"embedHtml"=>value} }
|
18
|
+
it { expect(player.embed_html).to be value }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -63,6 +63,7 @@ describe Yt::Video, :device_app do
|
|
63
63
|
expect(video.scheduled_start_time).to be_nil
|
64
64
|
expect(video.scheduled_end_time).to be_nil
|
65
65
|
expect(video.concurrent_viewers).to be_nil
|
66
|
+
expect(video.embed_html).to be_a String
|
66
67
|
end
|
67
68
|
|
68
69
|
it { expect{video.update}.to fail }
|
@@ -241,7 +241,7 @@ describe Yt::ContentOwner, :partner do
|
|
241
241
|
# Therefore, the test is commented out, otherwise a new asset would
|
242
242
|
# be created every time the test is run.
|
243
243
|
# describe 'assets can be added' do
|
244
|
-
# let(:params) { {type: 'web'} }
|
244
|
+
# let(:params) { {type: 'web', metadata_mine: {title: "Test Asset Title"}} }
|
245
245
|
# before { @asset = $content_owner.create_asset params }
|
246
246
|
# after { @asset.delete } # This does not seem to work
|
247
247
|
# it { expect(@asset).to be_a Yt::Asset }
|
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.15.
|
4
|
+
version: 0.15.2
|
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-04-
|
11
|
+
date: 2015-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/yt/collections/live_streaming_details.rb
|
147
147
|
- lib/yt/collections/ownerships.rb
|
148
148
|
- lib/yt/collections/partnered_channels.rb
|
149
|
+
- lib/yt/collections/players.rb
|
149
150
|
- lib/yt/collections/playlist_items.rb
|
150
151
|
- lib/yt/collections/playlists.rb
|
151
152
|
- lib/yt/collections/policies.rb
|
@@ -193,6 +194,7 @@ files:
|
|
193
194
|
- lib/yt/models/live_streaming_detail.rb
|
194
195
|
- lib/yt/models/match_policy.rb
|
195
196
|
- lib/yt/models/ownership.rb
|
197
|
+
- lib/yt/models/player.rb
|
196
198
|
- lib/yt/models/playlist.rb
|
197
199
|
- lib/yt/models/playlist_item.rb
|
198
200
|
- lib/yt/models/policy.rb
|
@@ -239,6 +241,7 @@ files:
|
|
239
241
|
- spec/models/description_spec.rb
|
240
242
|
- spec/models/live_streaming_detail_spec.rb
|
241
243
|
- spec/models/ownership_spec.rb
|
244
|
+
- spec/models/player_spec.rb
|
242
245
|
- spec/models/playlist_item_spec.rb
|
243
246
|
- spec/models/playlist_spec.rb
|
244
247
|
- spec/models/policy_rule_spec.rb
|
@@ -340,6 +343,7 @@ test_files:
|
|
340
343
|
- spec/models/description_spec.rb
|
341
344
|
- spec/models/live_streaming_detail_spec.rb
|
342
345
|
- spec/models/ownership_spec.rb
|
346
|
+
- spec/models/player_spec.rb
|
343
347
|
- spec/models/playlist_item_spec.rb
|
344
348
|
- spec/models/playlist_spec.rb
|
345
349
|
- spec/models/policy_rule_spec.rb
|