yt 0.19.0 → 0.20.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/README.md +1 -1
- data/lib/yt/associations/has_reports.rb +80 -44
- data/lib/yt/models/annotation.rb +1 -0
- data/lib/yt/models/asset.rb +0 -2
- data/lib/yt/models/channel.rb +186 -119
- data/lib/yt/models/claim.rb +0 -5
- data/lib/yt/models/content_owner_detail.rb +1 -25
- data/lib/yt/models/id.rb +1 -0
- data/lib/yt/models/playlist.rb +124 -38
- data/lib/yt/models/playlist_item.rb +62 -16
- data/lib/yt/models/reference.rb +0 -6
- data/lib/yt/models/resource.rb +11 -0
- data/lib/yt/models/snippet.rb +6 -96
- data/lib/yt/models/statistics_set.rb +1 -19
- data/lib/yt/models/status.rb +0 -2
- data/lib/yt/models/video.rb +24 -36
- data/lib/yt/version.rb +1 -1
- data/spec/models/channel_spec.rb +107 -0
- data/spec/models/content_owner_detail_spec.rb +0 -24
- data/spec/models/playlist_item_spec.rb +95 -6
- data/spec/models/playlist_spec.rb +87 -0
- data/spec/models/snippet_spec.rb +1 -118
- data/spec/models/statistics_set_spec.rb +1 -64
- data/spec/models/video_spec.rb +112 -0
- data/spec/requests/as_account/channel_spec.rb +1 -1
- data/spec/requests/as_account/playlist_item_spec.rb +1 -1
- data/spec/requests/as_account/playlist_spec.rb +1 -1
- data/spec/requests/as_account/video_spec.rb +2 -2
- data/spec/requests/as_content_owner/content_owner_spec.rb +4 -4
- data/spec/requests/as_content_owner/playlist_spec.rb +259 -0
- data/spec/requests/as_content_owner/video_spec.rb +38 -0
- metadata +1 -1
@@ -69,8 +69,8 @@ describe Yt::ContentOwner, :partner do
|
|
69
69
|
expect(claim.id).to be_a String
|
70
70
|
expect(claim.asset_id).to be_a String
|
71
71
|
expect(claim.video_id).to be_a String
|
72
|
-
expect(claim.status).to
|
73
|
-
expect(claim.content_type).to
|
72
|
+
expect(claim.status).to be_a String
|
73
|
+
expect(claim.content_type).to be_a String
|
74
74
|
expect(claim.created_at).to be_a Time
|
75
75
|
expect(claim).not_to be_third_party
|
76
76
|
end
|
@@ -189,8 +189,8 @@ describe Yt::ContentOwner, :partner do
|
|
189
189
|
expect(reference.audioswap_enabled?).to be_in [true, false]
|
190
190
|
expect(reference.ignore_fp_match?).to be_in [true, false]
|
191
191
|
expect(reference.urgent?).to be_in [true, false]
|
192
|
-
expect(reference.status).to
|
193
|
-
expect(reference.content_type).to
|
192
|
+
expect(reference.status).to be_a String
|
193
|
+
expect(reference.content_type).to be_a String
|
194
194
|
end
|
195
195
|
end
|
196
196
|
|
@@ -57,6 +57,265 @@ describe Yt::Playlist, :partner do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
describe 'views can be grouped by traffic source' do
|
61
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
62
|
+
let(:keys) { Yt::Collections::Reports::TRAFFIC_SOURCES.keys }
|
63
|
+
|
64
|
+
specify 'with the :by option set to :traffic_source' do
|
65
|
+
views = playlist.views range.merge by: :traffic_source
|
66
|
+
expect(views.keys - keys).to be_empty
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe 'views can be grouped by playback location' do
|
71
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
72
|
+
let(:keys) { Yt::Collections::Reports::PLAYBACK_LOCATIONS.keys }
|
73
|
+
|
74
|
+
specify 'with the :by option set to :playback_location' do
|
75
|
+
views = playlist.views range.merge by: :playback_location
|
76
|
+
expect(views.keys - keys).to be_empty
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'views can be grouped by related video' do
|
81
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
82
|
+
|
83
|
+
specify 'with the :by option set to :related_video' do
|
84
|
+
views = playlist.views range.merge by: :related_video
|
85
|
+
expect(views.keys).to all(be_instance_of Yt::Video)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'views can be grouped by video' do
|
90
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
91
|
+
|
92
|
+
specify 'with the :by option set to :video' do
|
93
|
+
views = playlist.views range.merge by: :video
|
94
|
+
expect(views.keys).to all(be_instance_of Yt::Video)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe 'views can be grouped by playlist' do
|
99
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
100
|
+
|
101
|
+
specify 'with the :by option set to :playlist' do
|
102
|
+
views = playlist.views range.merge by: :playlist
|
103
|
+
expect(views.keys).to all(be_instance_of Yt::Playlist)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe 'views can be grouped by device type' do
|
108
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
109
|
+
|
110
|
+
specify 'with the :by option set to :device_type' do
|
111
|
+
views = playlist.views range.merge by: :device_type
|
112
|
+
expect(views.keys).to all(be_instance_of Symbol)
|
113
|
+
expect(views.values).to all(be_instance_of Float)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe 'estimated minutes watched can be retrieved for a specific day' do
|
118
|
+
context 'in which the playlist was viewed' do
|
119
|
+
let(:views) { playlist.estimated_minutes_watched_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
|
120
|
+
it { expect(views).to be_a Float }
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'in which the playlist was not viewed' do
|
124
|
+
let(:views) { playlist.estimated_minutes_watched_on 20.years.ago}
|
125
|
+
it { expect(views).to be_nil }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe 'estimated minutes watched can be retrieved for a range of days' do
|
130
|
+
let(:date) { 4.days.ago }
|
131
|
+
|
132
|
+
specify 'with a given start (:since option)' do
|
133
|
+
expect(playlist.estimated_minutes_watched(since: date).keys.min).to eq date.to_date
|
134
|
+
end
|
135
|
+
|
136
|
+
specify 'with a given end (:until option)' do
|
137
|
+
expect(playlist.estimated_minutes_watched(until: date).keys.max).to eq date.to_date
|
138
|
+
end
|
139
|
+
|
140
|
+
specify 'with a given start (:from option)' do
|
141
|
+
expect(playlist.estimated_minutes_watched(from: date).keys.min).to eq date.to_date
|
142
|
+
end
|
143
|
+
|
144
|
+
specify 'with a given end (:to option)' do
|
145
|
+
expect(playlist.estimated_minutes_watched(to: date).keys.max).to eq date.to_date
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe 'estimated minutes watched can be grouped by day' do
|
150
|
+
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
151
|
+
let(:keys) { range.values }
|
152
|
+
|
153
|
+
specify 'without a :by option (default)' do
|
154
|
+
minutes = playlist.estimated_minutes_watched range
|
155
|
+
expect(minutes.keys).to eq range.values
|
156
|
+
end
|
157
|
+
|
158
|
+
specify 'with the :by option set to :day' do
|
159
|
+
minutes = playlist.estimated_minutes_watched range.merge by: :day
|
160
|
+
expect(minutes.keys).to eq range.values
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
describe 'estimated minutes watched can be grouped by traffic source' do
|
165
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
166
|
+
let(:keys) { Yt::Collections::Reports::TRAFFIC_SOURCES.keys }
|
167
|
+
|
168
|
+
specify 'with the :by option set to :traffic_source' do
|
169
|
+
minutes = playlist.estimated_minutes_watched range.merge by: :traffic_source
|
170
|
+
expect(minutes.keys - keys).to be_empty
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe 'estimated minutes watched can be grouped by playback location' do
|
175
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
176
|
+
let(:keys) { Yt::Collections::Reports::PLAYBACK_LOCATIONS.keys }
|
177
|
+
|
178
|
+
specify 'with the :by option set to :playback_location' do
|
179
|
+
minutes = playlist.estimated_minutes_watched range.merge by: :playback_location
|
180
|
+
expect(minutes.keys - keys).to be_empty
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
describe 'estimated minutes watched can be grouped by related video' do
|
185
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
186
|
+
|
187
|
+
specify 'with the :by option set to :related_video' do
|
188
|
+
minutes = playlist.estimated_minutes_watched range.merge by: :related_video
|
189
|
+
expect(minutes.keys).to all(be_instance_of Yt::Video)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe 'estimated minutes watched can be grouped by video' do
|
194
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
195
|
+
|
196
|
+
specify 'with the :by option set to :video' do
|
197
|
+
minutes = playlist.estimated_minutes_watched range.merge by: :video
|
198
|
+
expect(minutes.keys).to all(be_instance_of Yt::Video)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
describe 'estimated minutes watched can be grouped by playlist' do
|
203
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
204
|
+
|
205
|
+
specify 'with the :by option set to :playlist' do
|
206
|
+
minutes = playlist.estimated_minutes_watched range.merge by: :playlist
|
207
|
+
expect(minutes.keys).to all(be_instance_of Yt::Playlist)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe 'estimated minutes watched can be grouped by device type' do
|
212
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
213
|
+
|
214
|
+
specify 'with the :by option set to :device_type' do
|
215
|
+
minutes = playlist.estimated_minutes_watched range.merge by: :device_type
|
216
|
+
expect(minutes.keys).to all(be_instance_of Symbol)
|
217
|
+
expect(minutes.values).to all(be_instance_of Float)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
describe 'viewer percentage can be retrieved for a range of days' do
|
222
|
+
let(:viewer_percentage) { playlist.viewer_percentage since: 1.year.ago, until: 10.days.ago}
|
223
|
+
it { expect(viewer_percentage).to be_a Hash }
|
224
|
+
end
|
225
|
+
|
226
|
+
describe 'viewer_percentage can be grouped by gender and age group' do
|
227
|
+
let(:range) { {since: 1.year.ago.to_date, until: 1.week.ago.to_date} }
|
228
|
+
let(:keys) { range.values }
|
229
|
+
|
230
|
+
specify 'without a :by option (default)' do
|
231
|
+
viewer_percentage = playlist.viewer_percentage range
|
232
|
+
expect(viewer_percentage.keys).to match_array [:female, :male]
|
233
|
+
expect(viewer_percentage[:female].keys - %w(65- 35-44 45-54 13-17 25-34 55-64 18-24)).to be_empty
|
234
|
+
expect(viewer_percentage[:female].values).to all(be_instance_of Float)
|
235
|
+
expect(viewer_percentage[:male].keys - %w(65- 35-44 45-54 13-17 25-34 55-64 18-24)).to be_empty
|
236
|
+
expect(viewer_percentage[:male].values).to all(be_instance_of Float)
|
237
|
+
end
|
238
|
+
|
239
|
+
specify 'with the :by option set to :gender_age_group' do
|
240
|
+
viewer_percentage = playlist.viewer_percentage range.merge by: :gender_age_group
|
241
|
+
expect(viewer_percentage.keys).to match_array [:female, :male]
|
242
|
+
expect(viewer_percentage[:female].keys - %w(65- 35-44 45-54 13-17 25-34 55-64 18-24)).to be_empty
|
243
|
+
expect(viewer_percentage[:female].values).to all(be_instance_of Float)
|
244
|
+
expect(viewer_percentage[:male].keys - %w(65- 35-44 45-54 13-17 25-34 55-64 18-24)).to be_empty
|
245
|
+
expect(viewer_percentage[:male].values).to all(be_instance_of Float)
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe 'viewer_percentage can be grouped by gender' do
|
250
|
+
let(:range) { {since: 1.year.ago.to_date, until: 1.week.ago.to_date} }
|
251
|
+
let(:keys) { range.values }
|
252
|
+
|
253
|
+
specify 'with the :by option set to :gender' do
|
254
|
+
viewer_percentage = playlist.viewer_percentage range.merge by: :gender
|
255
|
+
expect(viewer_percentage.keys).to match_array [:female, :male]
|
256
|
+
expect(viewer_percentage[:female]).to be_a Float
|
257
|
+
expect(viewer_percentage[:male]).to be_a Float
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
describe 'viewer_percentage can be grouped by age group' do
|
262
|
+
let(:range) { {since: 1.year.ago.to_date, until: 1.week.ago.to_date} }
|
263
|
+
let(:keys) { range.values }
|
264
|
+
|
265
|
+
specify 'with the :by option set to :age_group' do
|
266
|
+
viewer_percentage = playlist.viewer_percentage range.merge by: :age_group
|
267
|
+
expect(viewer_percentage.keys - %w(65- 35-44 45-54 13-17 25-34 55-64 18-24)).to be_empty
|
268
|
+
expect(viewer_percentage.values).to all(be_instance_of Float)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
describe 'average view duration can be retrieved for a specific day' do
|
273
|
+
context 'in which the playlist was partnered' do
|
274
|
+
let(:average_view_duration) { playlist.average_view_duration_on 5.days.ago}
|
275
|
+
it { expect(average_view_duration).to be_a Float }
|
276
|
+
end
|
277
|
+
|
278
|
+
context 'in which the playlist was not partnered' do
|
279
|
+
let(:average_view_duration) { playlist.average_view_duration_on 20.years.ago}
|
280
|
+
it { expect(average_view_duration).to be_nil }
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
describe 'average view duration can be retrieved for a range of days' do
|
285
|
+
let(:date) { 4.days.ago }
|
286
|
+
|
287
|
+
specify 'with a given start (:since option)' do
|
288
|
+
expect(playlist.average_view_duration(since: date).keys.min).to eq date.to_date
|
289
|
+
end
|
290
|
+
|
291
|
+
specify 'with a given end (:until option)' do
|
292
|
+
expect(playlist.average_view_duration(until: date).keys.max).to eq date.to_date
|
293
|
+
end
|
294
|
+
|
295
|
+
specify 'with a given start (:from option)' do
|
296
|
+
expect(playlist.average_view_duration(from: date).keys.min).to eq date.to_date
|
297
|
+
end
|
298
|
+
|
299
|
+
specify 'with a given end (:to option)' do
|
300
|
+
expect(playlist.average_view_duration(to: date).keys.max).to eq date.to_date
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
describe 'average view duration can be grouped by day' do
|
305
|
+
let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
|
306
|
+
let(:keys) { range.values }
|
307
|
+
|
308
|
+
specify 'without a :by option (default)' do
|
309
|
+
average_view_duration = playlist.average_view_duration range
|
310
|
+
expect(average_view_duration.keys).to eq range.values
|
311
|
+
end
|
312
|
+
|
313
|
+
specify 'with the :by option set to :day' do
|
314
|
+
average_view_duration = playlist.average_view_duration range.merge by: :day
|
315
|
+
expect(average_view_duration.keys).to eq range.values
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
60
319
|
describe 'playlist starts can be retrieved for a specific day' do
|
61
320
|
context 'in which the playlist was viewed' do
|
62
321
|
let(:playlist_starts) { playlist.playlist_starts_on ENV['YT_TEST_PARTNER_PLAYLIST_DATE']}
|
@@ -565,6 +565,44 @@ describe Yt::Video, :partner do
|
|
565
565
|
end
|
566
566
|
end
|
567
567
|
|
568
|
+
describe 'estimated minutes watched can be grouped by playback location' do
|
569
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
570
|
+
let(:keys) { Yt::Collections::Reports::PLAYBACK_LOCATIONS.keys }
|
571
|
+
|
572
|
+
specify 'with the :by option set to :playback_location' do
|
573
|
+
estimated_minutes_watched = video.estimated_minutes_watched range.merge by: :playback_location
|
574
|
+
expect(estimated_minutes_watched.keys - keys).to be_empty
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
578
|
+
describe 'estimated minutes watched can be grouped by embedded player location' do
|
579
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
580
|
+
|
581
|
+
specify 'with the :by option set to :embedded_player_location' do
|
582
|
+
estimated_minutes_watched = video.estimated_minutes_watched range.merge by: :embedded_player_location
|
583
|
+
expect(estimated_minutes_watched).not_to be_empty
|
584
|
+
end
|
585
|
+
end
|
586
|
+
|
587
|
+
describe 'estimated minutes watched can be grouped by related video' do
|
588
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
589
|
+
|
590
|
+
specify 'with the :by option set to :related_video' do
|
591
|
+
estimated_minutes_watched = video.estimated_minutes_watched range.merge by: :related_video
|
592
|
+
expect(estimated_minutes_watched.keys).to all(be_instance_of Yt::Video)
|
593
|
+
end
|
594
|
+
end
|
595
|
+
|
596
|
+
describe 'estimated minutes watched can be grouped by device type' do
|
597
|
+
let(:range) { {since: 4.days.ago, until: 3.days.ago} }
|
598
|
+
|
599
|
+
specify 'with the :by option set to :device_type' do
|
600
|
+
estimated_minutes_watched = video.estimated_minutes_watched range.merge by: :device_type
|
601
|
+
expect(estimated_minutes_watched.keys).to all(be_instance_of Symbol)
|
602
|
+
expect(estimated_minutes_watched.values).to all(be_instance_of Float)
|
603
|
+
end
|
604
|
+
end
|
605
|
+
|
568
606
|
describe 'average view duration can be retrieved for a specific day' do
|
569
607
|
context 'in which the video was partnered' do
|
570
608
|
let(:average_view_duration) { video.average_view_duration_on 5.days.ago}
|