yt 0.14.3 → 0.14.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d1eeefafcd75a3c1c5f93117c6f5d08ab882569
4
- data.tar.gz: 48aafacb7c44c358ca7e4d32dd3cac022e50835a
3
+ metadata.gz: ac3b279f2bcc4efa9194c125ce7ca64741dcc61f
4
+ data.tar.gz: 0e212a30198ac5bc8e34efadb0cd90ff4bf324ea
5
5
  SHA512:
6
- metadata.gz: ff3234ddd12713b1ef8ab0d291cb154be0db0d673272c2aa50f602c358a8c9f0617ca1505b6a11f027f42b06fed5244346e0d85b9c429192d803da8ae49d0da6
7
- data.tar.gz: 2cf90341fe38289cbcbabcb1e2543b347bd9ca00e6eed81d49fae81845b457df15e7dc429d89c98ed743de0c5a7b99819f2b4e16ccff1952fb36dab15283e28b
6
+ metadata.gz: c322a11b50cad429ff7dfa5d594067dedd80971dd53614d62eefff4b7935740179eba9f9587c64fe9fb60b548bd37eb86cf39860198c29cbc5e670fa75243ef8
7
+ data.tar.gz: 4a96924e562e534ce0fc44db33bc1d97df6ec29cc310e3286db7cde6e52edfcf3f33444d23229a80c7929b7f56318d19d351bf9b5c38cf088704e547f5cd8499
@@ -6,6 +6,12 @@ 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.14.4 - 2015-04-14
10
+
11
+ * [FEATURE] New `by: :embedded_player_location` option for reports, to return views and estimated watched minutes (channels) by URL where the player was embedded
12
+ * [FEATURE] New `by: :playback_location` option for reports, to return views and estimated watched minutes (channels) by watch/embedded/channel/external app/mobile.
13
+ * [FEATURE] New `by: :related_video` option for reports, to return views and estimated watched minutes (channels) by the video that linked there.
14
+
9
15
  ## 0.14.3 - 2015-04-09
10
16
 
11
17
  * [BUGFIX] Don't let request errors crash Yt in Ruby 1.9.3.
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.14.3'
44
+ gem 'yt', '~> 0.14.4'
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*)
@@ -150,6 +150,9 @@ Use [Yt::Channel](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Chan
150
150
  * delete playlists from a channel
151
151
  * retrieve the daily earnings, views, comments, likes, dislikes, shares, subscribers gained/lost, estimated/average video watch and impressions of a channel by day
152
152
  * retrieve the views and estimated minutes watched by traffic source
153
+ * retrieve the views and estimated minutes watched by playback location
154
+ * retrieve the views and estimated minutes watched by embedded player location
155
+ * retrieve the views and estimated minutes watched by related video
153
156
  * retrieve the views and estimated minutes watched by video
154
157
  * retrieve the views and estimated minutes watched by playlist
155
158
  * retrieve the viewer percentage of a channel by gender and age group
@@ -217,6 +220,15 @@ channel.viewer_percentage(gender: :male) #=> 49.12
217
220
  channel.views since: 7.days.ago, by: :traffic_source #=> {advertising: 10.0, related_video: 20.0, promoted: 5.0, subscriber: 1.0, channel: 3.0, other: 7.0}
218
221
  channel.estimated_minutes_watched since: 7.days.ago, by: :traffic_source #=> {annotation: 10.0, external_app: 20.0, external_url: 5.0, embedded: 1.0, search: 3.0}
219
222
 
223
+ channel.views since: 7.days.ago, by: :playback_location #=> {embedded: 34.0, watch: 467.0, channel: 462.0, other: 3.0}
224
+ channel.estimated_minutes_watched since: 7.days.ago, by: :playback_location #=> {embedded: 34.0, watch: 467.0, channel: 462.0, other: 3.0}
225
+
226
+ channel.views since: 7.days.ago, by: :embedded_player_location #=> {"fullscreen.net"=>45.0, "linkedin.com"=>5.0, "mashable.com"=>1.0, "unknown"=>1.0}
227
+ channel.estimated_minutes_watched since: 7.days.ago, by: :embedded_player_location #=> {"fullscreen.net"=>45.0, "linkedin.com"=>5.0, "mashable.com"=>1.0, "unknown"=>1.0}
228
+
229
+ channel.views since: 7.days.ago, by: :related_video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
230
+ channel.estimated_minutes_watched since: 7.days.ago, by: :related_video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
231
+
220
232
  channel.views since: 7.days.ago, by: :video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
221
233
  channel.estimated_minutes_watched since: 7.days.ago, by: :video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
222
234
 
@@ -246,6 +258,12 @@ channel.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}
246
258
  channel.viewer_percentage(gender: :female) #=> 49.12
247
259
  channel.views since: 7.days.ago, by: :traffic_source #=> {advertising: 10.0, related_video: 20.0, promoted: 5.0, subscriber: 1.0, channel: 3.0, other: 7.0}
248
260
  channel.estimated_minutes_watched since: 7.days.ago, by: :traffic_source #=> {annotation: 10.0, external_app: 20.0, external_url: 5.0, embedded: 1.0, search: 3.0}
261
+ channel.views since: 7.days.ago, by: :playback_location #=> {embedded: 34.0, watch: 467.0, channel: 462.0, other: 3.0}
262
+ channel.estimated_minutes_watched since: 7.days.ago, by: :playback_location #=> {embedded: 34.0, watch: 467.0, channel: 462.0, other: 3.0}
263
+ channel.views since: 7.days.ago, by: :embedded_player_location #=> {"fullscreen.net"=>45.0, "linkedin.com"=>5.0, "mashable.com"=>1.0, "unknown"=>1.0}
264
+ channel.estimated_minutes_watched since: 7.days.ago, by: :embedded_player_location #=> {"fullscreen.net"=>45.0, "linkedin.com"=>5.0, "mashable.com"=>1.0, "unknown"=>1.0}
265
+ channel.views since: 7.days.ago, by: :related_video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
266
+ channel.estimated_minutes_watched since: 7.days.ago, by: :related_video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
249
267
  channel.views since: 7.days.ago, by: :video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
250
268
  channel.estimated_minutes_watched since: 7.days.ago, by: :video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
251
269
  channel.views since: 7.days.ago, by: :playlist #=> {#<Yt::Models::Playlist @id=...>: 10.0, #<Yt::Models::Playlist @id=...>: 20.0, …}
@@ -271,6 +289,9 @@ Use [Yt::Video](http://rubydoc.info/github/Fullscreen/yt/master/Yt/Models/Video)
271
289
  * like and dislike a video
272
290
  * retrieve the daily earnings, views, comments, likes, dislikes, shares, subscribers gained/lost, impressions and monetized playbacks of a video by day
273
291
  * retrieve the views of a video by traffic source
292
+ * retrieve the views of a video by playback location
293
+ * retrieve the views of a video by embedded player location
294
+ * retrieve the views of a video by related video
274
295
  * retrieve the viewer percentage of a video by gender and age group
275
296
  * retrieve data about live-streaming videos
276
297
  * retrieve the advertising options of a video
@@ -372,6 +393,9 @@ video.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}
372
393
  video.viewer_percentage(gender: :female) #=> 49.12
373
394
 
374
395
  video.views since: 7.days.ago, by: :traffic_source #=> {advertising: 10.0, related_video: 20.0, promoted: 5.0, subscriber: 1.0, channel: 3.0, other: 7.0}
396
+ video.views since: 7.days.ago, by: :playback_location #=> {:embedded=>6.0, :watch=>11.0}
397
+ video.views since: 7.days.ago, by: :embedded_player_location #=> {"fullscreen.net"=>45.0, "linkedin.com"=>5.0, "mashable.com"=>1.0, "unknown"=>1.0}
398
+ video.views since: 7.days.ago, by: :related_video #=> {#<Yt::Models::Video @id=...>: 10.0, #<Yt::Models::Video @id=...>: 20.0, …}
375
399
 
376
400
  video.delete #=> true
377
401
  ```
@@ -402,6 +426,7 @@ video.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}
402
426
  video.viewer_percentage(gender: :female) #=> 49.12
403
427
 
404
428
  video.views since: 7.days.ago, by: :traffic_source #=> {advertising: 10.0, related_video: 20.0, promoted: 5.0, subscriber: 1.0, channel: 3.0, other: 7.0}
429
+ video.views since: 7.days.ago, by: :playback_location #=> {:embedded=>6.0, :watch=>11.0}
405
430
 
406
431
  video.ad_formats #=> ["standard_instream", "trueview_instream"]
407
432
  ```
@@ -5,6 +5,9 @@ module Yt
5
5
  class Reports < Base
6
6
  DIMENSIONS = Hash.new({name: 'day', parse: ->(day) {Date.iso8601 day} }).tap do |hash|
7
7
  hash[:traffic_source] = {name: 'insightTrafficSourceType', parse: ->(type) {TRAFFIC_SOURCES.key type} }
8
+ hash[:playback_location] = {name: 'insightPlaybackLocationType', parse: ->(type) {PLAYBACK_LOCATIONS.key type} }
9
+ hash[:embedded_player_location] = {name: 'insightPlaybackLocationDetail', parse: ->(url) {url} }
10
+ hash[:related_video] = {name: 'insightTrafficSourceDetail', parse: ->(video_id) { Yt::Video.new id: video_id, auth: @auth } }
8
11
  hash[:video] = {name: 'video', parse: ->(video_id) { Yt::Video.new id: video_id, auth: @auth } }
9
12
  hash[:playlist] = {name: 'playlist', parse: ->(playlist_id) { Yt::Playlist.new id: playlist_id, auth: @auth } }
10
13
  end
@@ -27,6 +30,16 @@ module Yt
27
30
  search: 'YT_SEARCH',
28
31
  }
29
32
 
33
+ # @see https://developers.google.com/youtube/analytics/v1/dimsmets/dims#Playback_Location_Dimensions
34
+ PLAYBACK_LOCATIONS = {
35
+ channel: 'CHANNEL',
36
+ watch: 'WATCH',
37
+ embedded: 'EMBEDDED',
38
+ other: 'YT_OTHER',
39
+ external_app: 'EXTERNAL_APP',
40
+ mobile: 'MOBILE' # only present for data < September 10, 2013
41
+ }
42
+
30
43
  attr_writer :metric
31
44
 
32
45
  def within(days_range, dimension, try_again = true)
@@ -66,8 +79,12 @@ module Yt
66
79
  params['dimensions'] = DIMENSIONS[@dimension][:name]
67
80
  params['max-results'] = 10 if @dimension == :video
68
81
  params['max-results'] = 200 if @dimension == :playlist
69
- params['sort'] = "-#{@metric.to_s.camelize(:lower)}" if @dimension.in? [:video, :playlist]
82
+ params['max-results'] = 25 if @dimension == :embedded_player_location
83
+ params['max-results'] = 25 if @dimension == :related_video
84
+ params['sort'] = "-#{@metric.to_s.camelize(:lower)}" if @dimension.in? [:video, :playlist, :embedded_player_location, :related_video]
70
85
  params[:filters] = ((params[:filters] || '').split(';') + ['isCurated==1']).compact.uniq.join(';') if @dimension == :playlist
86
+ params[:filters] = ((params[:filters] || '').split(';') + ['insightPlaybackLocationType==EMBEDDED']).compact.uniq.join(';') if @dimension == :embedded_player_location
87
+ params[:filters] = ((params[:filters] || '').split(';') + ['insightTrafficSourceType==RELATED_VIDEO']).compact.uniq.join(';') if @dimension == :related_video
71
88
  end
72
89
  end
73
90
 
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.14.3'
2
+ VERSION = '0.14.4'
3
3
  end
@@ -112,6 +112,34 @@ describe Yt::Channel, :partner do
112
112
  end
113
113
  end
114
114
 
115
+ describe 'views can be grouped by playback location' do
116
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
117
+ let(:keys) { Yt::Collections::Reports::PLAYBACK_LOCATIONS.keys }
118
+
119
+ specify 'with the :by option set to :playback_location' do
120
+ views = channel.views range.merge by: :playback_location
121
+ expect(views.keys - keys).to be_empty
122
+ end
123
+ end
124
+
125
+ describe 'views can be grouped by embedded player location' do
126
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
127
+
128
+ specify 'with the :by option set to :embedded_player_location' do
129
+ views = channel.views range.merge by: :embedded_player_location
130
+ expect(views).not_to be_empty
131
+ end
132
+ end
133
+
134
+ describe 'views can be grouped by related video' do
135
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
136
+
137
+ specify 'with the :by option set to :related_video' do
138
+ views = channel.views range.merge by: :related_video
139
+ expect(views.keys).to all(be_instance_of Yt::Video)
140
+ end
141
+ end
142
+
115
143
  describe 'views can be grouped by video' do
116
144
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
117
145
 
@@ -563,6 +591,34 @@ describe Yt::Channel, :partner do
563
591
  end
564
592
  end
565
593
 
594
+ describe 'estimated minutes watched can be grouped by playback location' do
595
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
596
+ let(:keys) { Yt::Collections::Reports::PLAYBACK_LOCATIONS.keys }
597
+
598
+ specify 'with the :by option set to :playback_location' do
599
+ estimated_minutes_watched = channel.estimated_minutes_watched range.merge by: :playback_location
600
+ expect(estimated_minutes_watched.keys - keys).to be_empty
601
+ end
602
+ end
603
+
604
+ describe 'estimated minutes watched can be grouped by embedded player location' do
605
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
606
+
607
+ specify 'with the :by option set to :embedded_player_location' do
608
+ estimated_minutes_watched = channel.estimated_minutes_watched range.merge by: :embedded_player_location
609
+ expect(estimated_minutes_watched).not_to be_empty
610
+ end
611
+ end
612
+
613
+ describe 'estimated minutes watched can be grouped by related video' do
614
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
615
+
616
+ specify 'with the :by option set to :related_video' do
617
+ estimated_minutes_watched = channel.estimated_minutes_watched range.merge by: :related_video
618
+ expect(estimated_minutes_watched.keys).to all(be_instance_of Yt::Video)
619
+ end
620
+ end
621
+
566
622
  describe 'estimated minutes watched can be grouped by video' do
567
623
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
568
624
 
@@ -102,6 +102,34 @@ describe Yt::Video, :partner do
102
102
  end
103
103
  end
104
104
 
105
+ describe 'views can be grouped by playback location' do
106
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
107
+ let(:keys) { Yt::Collections::Reports::PLAYBACK_LOCATIONS.keys }
108
+
109
+ specify 'with the :by option set to :playback_location' do
110
+ views = video.views range.merge by: :playback_location
111
+ expect(views.keys - keys).to be_empty
112
+ end
113
+ end
114
+
115
+ describe 'views can be grouped by embedded player location' do
116
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
117
+
118
+ specify 'with the :by option set to :embedded_player_location' do
119
+ views = video.views range.merge by: :embedded_player_location
120
+ expect(views).not_to be_empty
121
+ end
122
+ end
123
+
124
+ describe 'views can be grouped by related video' do
125
+ let(:range) { {since: 4.days.ago, until: 3.days.ago} }
126
+
127
+ specify 'with the :by option set to :related_video' do
128
+ views = video.views range.merge by: :related_video
129
+ expect(views.keys).to all(be_instance_of Yt::Video)
130
+ end
131
+ end
132
+
105
133
  describe 'comments can be retrieved for a specific day' do
106
134
  context 'in which the video was partnered' do
107
135
  let(:comments) { video.comments_on 5.days.ago}
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.14.3
4
+ version: 0.14.4
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-09 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport