yt 0.32.3 → 0.33.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -2
- data/.travis.yml +2 -4
- data/CHANGELOG.md +48 -2
- data/README.md +54 -41
- data/YOUTUBE_IT.md +4 -4
- data/bin/yt +2 -9
- data/lib/yt.rb +0 -1
- data/lib/yt/actions/get.rb +33 -0
- data/lib/yt/associations/has_reports.rb +9 -14
- data/lib/yt/collections/claims.rb +8 -0
- data/lib/yt/collections/content_owners.rb +6 -2
- data/lib/yt/collections/playlist_items.rb +10 -1
- data/lib/yt/collections/reports.rb +5 -7
- data/lib/yt/collections/snippets.rb +1 -1
- data/lib/yt/config.rb +54 -0
- data/lib/yt/models/account.rb +21 -1
- data/lib/yt/models/asset.rb +27 -4
- data/lib/yt/models/asset_metadata.rb +1 -1
- data/lib/yt/models/base.rb +2 -0
- data/lib/yt/models/channel.rb +2 -5
- data/lib/yt/models/claim.rb +11 -0
- data/lib/yt/models/configuration.rb +70 -0
- data/lib/yt/models/content_owner.rb +49 -0
- data/lib/yt/models/match_policy.rb +4 -6
- data/lib/yt/models/playlist.rb +12 -2
- data/lib/yt/models/playlist_item.rb +8 -1
- data/lib/yt/models/resource.rb +70 -4
- data/lib/yt/models/statistics_set.rb +2 -1
- data/lib/yt/models/url.rb +2 -60
- data/lib/yt/models/video.rb +16 -3
- data/lib/yt/request.rb +6 -2
- data/lib/yt/version.rb +1 -1
- data/yt.gemspec +6 -3
- metadata +44 -176
- data/spec/collections/claims_spec.rb +0 -30
- data/spec/collections/comment_threads_spec.rb +0 -46
- data/spec/collections/playlist_items_spec.rb +0 -44
- data/spec/collections/playlists_spec.rb +0 -27
- data/spec/collections/policies_spec.rb +0 -30
- data/spec/collections/references_spec.rb +0 -30
- data/spec/collections/reports_spec.rb +0 -30
- data/spec/collections/subscriptions_spec.rb +0 -25
- data/spec/collections/videos_spec.rb +0 -43
- data/spec/constants/geography_spec.rb +0 -16
- data/spec/errors/forbidden_spec.rb +0 -10
- data/spec/errors/missing_auth_spec.rb +0 -24
- data/spec/errors/no_items_spec.rb +0 -10
- data/spec/errors/request_error_spec.rb +0 -44
- data/spec/errors/server_error_spec.rb +0 -10
- data/spec/errors/unauthorized_spec.rb +0 -10
- data/spec/models/account_spec.rb +0 -138
- data/spec/models/annotation_spec.rb +0 -180
- data/spec/models/asset_spec.rb +0 -20
- data/spec/models/channel_spec.rb +0 -127
- data/spec/models/claim_event_spec.rb +0 -62
- data/spec/models/claim_history_spec.rb +0 -27
- data/spec/models/claim_spec.rb +0 -223
- data/spec/models/comment_spec.rb +0 -40
- data/spec/models/comment_thread_spec.rb +0 -93
- data/spec/models/content_detail_spec.rb +0 -52
- data/spec/models/content_owner_detail_spec.rb +0 -6
- data/spec/models/file_detail_spec.rb +0 -13
- data/spec/models/live_streaming_detail_spec.rb +0 -6
- data/spec/models/ownership_spec.rb +0 -59
- data/spec/models/player_spec.rb +0 -13
- data/spec/models/playlist_item_spec.rb +0 -120
- data/spec/models/playlist_spec.rb +0 -138
- data/spec/models/policy_rule_spec.rb +0 -63
- data/spec/models/policy_spec.rb +0 -41
- data/spec/models/rating_spec.rb +0 -12
- data/spec/models/reference_spec.rb +0 -249
- data/spec/models/request_spec.rb +0 -204
- data/spec/models/resource_spec.rb +0 -42
- data/spec/models/right_owner_spec.rb +0 -71
- data/spec/models/snippet_spec.rb +0 -13
- data/spec/models/statistics_set_spec.rb +0 -13
- data/spec/models/status_spec.rb +0 -13
- data/spec/models/subscription_spec.rb +0 -30
- data/spec/models/url_spec.rb +0 -78
- data/spec/models/video_category_spec.rb +0 -21
- data/spec/models/video_spec.rb +0 -669
- data/spec/requests/as_account/account_spec.rb +0 -148
- data/spec/requests/as_account/authentications_spec.rb +0 -127
- data/spec/requests/as_account/channel_spec.rb +0 -246
- data/spec/requests/as_account/channels_spec.rb +0 -18
- data/spec/requests/as_account/playlist_item_spec.rb +0 -55
- data/spec/requests/as_account/playlist_spec.rb +0 -218
- data/spec/requests/as_account/thumbnail.jpg +0 -0
- data/spec/requests/as_account/video.mp4 +0 -0
- data/spec/requests/as_account/video_spec.rb +0 -408
- data/spec/requests/as_content_owner/account_spec.rb +0 -29
- data/spec/requests/as_content_owner/advertising_options_set_spec.rb +0 -15
- data/spec/requests/as_content_owner/asset_spec.rb +0 -20
- data/spec/requests/as_content_owner/bulk_report_job_spec.rb +0 -19
- data/spec/requests/as_content_owner/channel_spec.rb +0 -1836
- data/spec/requests/as_content_owner/claim_history_spec.rb +0 -20
- data/spec/requests/as_content_owner/content_owner_spec.rb +0 -329
- data/spec/requests/as_content_owner/match_policy_spec.rb +0 -17
- data/spec/requests/as_content_owner/ownership_spec.rb +0 -25
- data/spec/requests/as_content_owner/playlist_spec.rb +0 -767
- data/spec/requests/as_content_owner/video_group_spec.rb +0 -112
- data/spec/requests/as_content_owner/video_spec.rb +0 -1211
- data/spec/requests/as_server_app/channel_spec.rb +0 -54
- data/spec/requests/as_server_app/comment_spec.rb +0 -22
- data/spec/requests/as_server_app/comment_thread_spec.rb +0 -27
- data/spec/requests/as_server_app/comment_threads_spec.rb +0 -41
- data/spec/requests/as_server_app/playlist_item_spec.rb +0 -30
- data/spec/requests/as_server_app/playlist_spec.rb +0 -33
- data/spec/requests/as_server_app/url_spec.rb +0 -94
- data/spec/requests/as_server_app/video_spec.rb +0 -60
- data/spec/requests/as_server_app/videos_spec.rb +0 -40
- data/spec/requests/unauthenticated/video_spec.rb +0 -14
- data/spec/spec_helper.rb +0 -20
- data/spec/support/fail_matcher.rb +0 -15
- data/spec/support/global_hooks.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94422f128aee1411a90f1fcb39a28ef13afa5f456bf15e9722eddcc3139a46c0
|
4
|
+
data.tar.gz: a8ee06716cc4018e217da1eb98ec416511e00f6f760f88cd11ab2b7f24dd6f24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28cab7081f268473eca6e3165389bd40411955dbc96046e6523bf87b9de1b3e216d121fdfb68dd474bc354fc7c3591bd2c395a03d1baa0d43e5c4e9372b346b3
|
7
|
+
data.tar.gz: 98454281ad9a072638d3a3a2f28d58ab8435258d55c2c167d3ff8dd6b89daf225e2d10dc0d473f3ecece6e9cd2205d1ab9c8957eeb15faf6b8c7ed52209b4966
|
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,52 @@ 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.33.0 - 2020-10-19
|
10
|
+
|
11
|
+
* [BUGFIX] Only retry once when exchanging a refresh token
|
12
|
+
|
13
|
+
## 0.33.0 - 2020-04-10
|
14
|
+
|
15
|
+
If your code calls reports methods such as `views`, `likes`, or `reports`,
|
16
|
+
do not include `by: :week` option since `7DayTotals` dimension will no longer be
|
17
|
+
supported by YouTube API as of [April 15, 2020](https://developers.google.com/youtube/analytics/revision_history#october-15,-2019).
|
18
|
+
|
19
|
+
Use `by: :day` option instead and add up the numbers from each day.
|
20
|
+
|
21
|
+
If you keep using `by: :week` option after this change it will raise an error
|
22
|
+
(before the gem upgrade) or it will run with `day` dimension instead (after
|
23
|
+
the gem upgrade, like any other random input).
|
24
|
+
|
25
|
+
* [REMOVAL] Remove `by: :week` option for reports.
|
26
|
+
* [FEATURE] Add back the option of initializing a resource by its URL.
|
27
|
+
* [BUGFIX] Limit retries on refreshing tokens
|
28
|
+
|
29
|
+
**Breaking change**
|
30
|
+
|
31
|
+
If your code is using constant `Yt::URL::CHANNEL_PATTERNS` etc then it's moved to `Yt::Resource::CHANNEL_PATTERNS`, `Yt::Resource::VIDEO_PATTERNS`, and `Yt::Resource::PLAYLIST_PATTERNS`.
|
32
|
+
|
33
|
+
## 0.32.6 - 2020-02-07
|
34
|
+
|
35
|
+
* [FEATURE] Allow partnered channels to delete playlist item.
|
36
|
+
* [FEATURE] Allow partnered channels to update video.
|
37
|
+
* [FEATURE] Allow partnered channels to update playlist.
|
38
|
+
* [FEATURE] Allow partnered channels to upload thumbnail.
|
39
|
+
* [FEATURE] Allow partnered channels to create playlist item.
|
40
|
+
|
41
|
+
## 0.32.5 - 2019-11-06
|
42
|
+
|
43
|
+
* [BUGFIX] Fix `MatchPolicy#update` and `Asset#update` by using `PUT` instead of `PATCH`
|
44
|
+
* Update `bin/yt` file to keep `yt info` command work
|
45
|
+
|
46
|
+
## 0.32.4 - 2019-06-26
|
47
|
+
|
48
|
+
* [FEATURE] Add `ownership_effective` method to access asset ownership ("effective") via the asset object.
|
49
|
+
* [FEATURE] List content owners of others with `content_owner.content_owners`
|
50
|
+
* [FEATURE] Add `match_info` to insert claim request.
|
51
|
+
* [FEATURE] Add `upload_reference_file` method for Reference file upload (thank you @jcohenho)
|
52
|
+
* [FEATURE] Get one asset [by request](https://developers.google.com/youtube/partner/docs/v1/assets/get) (thank you @jcohenho)
|
53
|
+
* [FEATURE] Add `update` method to Yt::Claim (thank you @jcohenho)
|
54
|
+
|
9
55
|
## 0.32.3 - 2019-03-15
|
10
56
|
|
11
57
|
* [ENHANCEMENT] Add `Yt::URL` to get id, kind, and its resource (channel, video, playlist)
|
@@ -448,11 +494,11 @@ If your code expects reports to return results **by day** then you **must** add
|
|
448
494
|
the `by: :day` option to your report method. The new default is `by: :range`.
|
449
495
|
For instance `channel.views` would return
|
450
496
|
|
451
|
-
|
497
|
+
{Wed, 8 May 2014 => 12.4, Thu, 9 May 2014 => 3.2, Fri, 10 May 2014 => …}
|
452
498
|
|
453
499
|
and now returns the same as calling `channel.views by: :range`:
|
454
500
|
|
455
|
-
|
501
|
+
{total: 3450}
|
456
502
|
|
457
503
|
Additionally, if you expect reports **by day** then you **must** specify the
|
458
504
|
`:since` option to your report method. Previously, this value was set to
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ The **source code** is available on [GitHub](https://github.com/Fullscreen/yt) a
|
|
8
8
|
[![Build Status](http://img.shields.io/travis/Fullscreen/yt/master.svg)](https://travis-ci.org/Fullscreen/yt)
|
9
9
|
[![Coverage Status](http://img.shields.io/coveralls/Fullscreen/yt/master.svg)](https://coveralls.io/r/Fullscreen/yt)
|
10
10
|
[![Dependency Status](http://img.shields.io/gemnasium/Fullscreen/yt.svg)](https://gemnasium.com/Fullscreen/yt)
|
11
|
-
[![Code Climate](
|
11
|
+
[![Code Climate](https://codeclimate.com/github/Fullscreen/yt.png)](https://codeclimate.com/github/Fullscreen/yt)
|
12
12
|
[![Online docs](http://img.shields.io/badge/docs-✓-green.svg)](http://www.rubydoc.info/gems/yt/frames)
|
13
13
|
[![Gem Version](http://img.shields.io/gem/v/yt.svg)](http://rubygems.org/gems/yt)
|
14
14
|
|
@@ -18,7 +18,6 @@ After [registering your app](#configuring-your-app), you can run commands like:
|
|
18
18
|
channel = Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow'
|
19
19
|
channel.title #=> "Fullscreen"
|
20
20
|
channel.public? #=> true
|
21
|
-
channel.comment_count #=> 773
|
22
21
|
channel.videos.count #=> 12
|
23
22
|
```
|
24
23
|
|
@@ -44,7 +43,7 @@ To install on your system, run
|
|
44
43
|
|
45
44
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
46
45
|
|
47
|
-
gem 'yt', '~> 0.
|
46
|
+
gem 'yt', '~> 0.32.0'
|
48
47
|
|
49
48
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
50
49
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
@@ -266,6 +265,11 @@ asset = content_owner.assets.where(id: 'A969176766549462', fetch_metadata: 'effe
|
|
266
265
|
asset.metadata_effective.title #=> "Neu la anh" (different due to ownership conflicts)
|
267
266
|
```
|
268
267
|
|
268
|
+
```ruby
|
269
|
+
asset = content_owner.assets.where(id: 'A125058570526569', fetch_ownership: 'effective').first
|
270
|
+
asset.ownership_effective.general_owners.first.owner # => "XOuN81q-MeEUVrsiZeK1lQ"
|
271
|
+
```
|
272
|
+
|
269
273
|
* to search for an asset
|
270
274
|
|
271
275
|
```ruby
|
@@ -295,6 +299,32 @@ claim.claim_history #=> #<Yt::Models::ClaimHistory ...>
|
|
295
299
|
claim.claim_history.events[0].type #=> "claim_create"
|
296
300
|
|
297
301
|
claim.delete #=> true
|
302
|
+
|
303
|
+
data = {
|
304
|
+
is_manual_claim: true,
|
305
|
+
content_type: 'audiovisual',
|
306
|
+
asset_id: 'A123123123123123',
|
307
|
+
policy: { id: 'S123123123123123' },
|
308
|
+
video_id: 'myvIdeoIdYT',
|
309
|
+
match_info: {
|
310
|
+
match_segments: [
|
311
|
+
{
|
312
|
+
manual_segment: {
|
313
|
+
start: '00:00:20.000',
|
314
|
+
finish: '00:01:20.000'
|
315
|
+
}
|
316
|
+
},
|
317
|
+
{
|
318
|
+
manual_segment: {
|
319
|
+
start: '00:02:30.000',
|
320
|
+
finish: '00:03:50.000'
|
321
|
+
}
|
322
|
+
}
|
323
|
+
]
|
324
|
+
}
|
325
|
+
}
|
326
|
+
|
327
|
+
content_owner.claims.insert(data)
|
298
328
|
```
|
299
329
|
|
300
330
|
*The methods above require to be authenticated as the video’s content owner (see below).*
|
@@ -492,55 +522,37 @@ end
|
|
492
522
|
so use the approach that you prefer.
|
493
523
|
If a variable is set in both places, then `Yt.configure` takes precedence.
|
494
524
|
|
495
|
-
Why you should use Yt…
|
496
|
-
======================
|
497
|
-
|
498
|
-
… and not [youtube_it](https://github.com/kylejginavan/youtube_it)?
|
499
|
-
Because youtube_it does not support YouTube API V3, and the YouTube API V2 has
|
500
|
-
been [officially deprecated as of March 4, 2014](https://developers.google.com/youtube/2.0/developers_guide_protocol_audience).
|
501
|
-
If you need help upgrading your code, check [YOUTUBE_IT.md](https://github.com/Fullscreen/yt/blob/master/YOUTUBE_IT.md),
|
502
|
-
a step-by-step comparison between youtube_it and Yt to make upgrade easier.
|
503
|
-
|
504
|
-
… and not [Google Api Client](https://github.com/google/google-api-ruby-client)?
|
505
|
-
Because Google Api Client is poorly coded, poorly documented and adds many
|
506
|
-
dependencies, bloating the size of your project.
|
507
|
-
|
508
|
-
… and not your own code? Because Yt is fully tested, well documented,
|
509
|
-
has few dependencies and helps you forget about the burden of dealing with
|
510
|
-
Google API!
|
511
|
-
|
512
525
|
How to test
|
513
526
|
===========
|
514
527
|
|
515
|
-
|
528
|
+
To run tests:
|
516
529
|
|
517
|
-
|
518
|
-
|
530
|
+
```bash
|
531
|
+
rspec
|
532
|
+
```
|
519
533
|
|
520
|
-
|
521
|
-
meant to really integrate Yt with YouTube. YouTube API is not exactly
|
522
|
-
*the most reliable* API out there, so we need to make sure that the responses
|
523
|
-
match the documentation.
|
534
|
+
We recommend RSpec >= 3.8.
|
524
535
|
|
525
|
-
|
526
|
-
Travis CI is already set up to do this for when whenever you push a branch
|
527
|
-
or create a pull request for this project.
|
536
|
+
Yt comes with two different sets of tests:
|
528
537
|
|
529
|
-
|
538
|
+
1. Unit tests in `spec/models`, `spec/collections` and `spec/errors`
|
539
|
+
2. Legacy integration tests in `spec/requests`
|
530
540
|
|
531
|
-
|
532
|
-
rspec spec/models spec/collections spec/errors
|
533
|
-
```
|
541
|
+
Coming soon will be a new set of high-level integration tests.
|
534
542
|
|
535
|
-
|
543
|
+
Integration tests are recorded with VCR. Some of the tests refer to
|
544
|
+
fixture data that an arbitrary account may not have access to. If you
|
545
|
+
need to modify one of these tests or re-record the cassette, we'd
|
546
|
+
suggest working against your own version of the testing setup. Then in
|
547
|
+
your pull request, we can help canonize your test/fixtures.
|
536
548
|
|
537
|
-
|
538
|
-
|
539
|
-
```
|
549
|
+
Some of the integration tests require authentication. These can be set
|
550
|
+
with the following environment variables:
|
540
551
|
|
541
|
-
|
542
|
-
|
543
|
-
|
552
|
+
* `YT_TEST_CLIENT_ID`
|
553
|
+
* `YT_TEST_CLIENT_SECRET`
|
554
|
+
* `YT_TEST_API_KEY`
|
555
|
+
* `YT_TEST_REFRESH_TOKEN`
|
544
556
|
|
545
557
|
How to release new versions
|
546
558
|
===========================
|
@@ -568,3 +580,4 @@ the [YouTube Analytics API](https://developers.google.com/youtube/analytics).
|
|
568
580
|
If you find that a method is missing, fork the project, add the missing code,
|
569
581
|
write the appropriate tests, then submit a pull request, and it will gladly
|
570
582
|
be merged!
|
583
|
+
|
data/YOUTUBE_IT.md
CHANGED
@@ -141,7 +141,7 @@ client = YouTubeIt::Client.new
|
|
141
141
|
client.videos_by(:query => "penguin", :author => "liz")
|
142
142
|
# with yt: the 'author' filter was removed from YouTube API V3, so the
|
143
143
|
# request must be done using the channel of the requested author
|
144
|
-
channel = Yt::Channel.new
|
144
|
+
channel = Yt::Channel.new url: 'youtube.com/liz'
|
145
145
|
channel.videos.where(q: 'penguin')
|
146
146
|
```
|
147
147
|
|
@@ -176,7 +176,7 @@ client = YouTubeIt::Client.new
|
|
176
176
|
client.videos_by(:user => 'liz')
|
177
177
|
# with yt: the 'author' filter was removed from YouTube API V3, so the
|
178
178
|
# request must be done using the channel of the requested author
|
179
|
-
channel = Yt::Channel.new
|
179
|
+
channel = Yt::Channel.new url: 'youtube.com/liz'
|
180
180
|
channel.videos.where(q: 'penguin')
|
181
181
|
```
|
182
182
|
|
@@ -188,7 +188,7 @@ client = YouTubeIt::Client.new
|
|
188
188
|
client.videos_by(:favorites, :user => 'liz')
|
189
189
|
# with yt: note that only *old* channels have a "Favorites" playlist, since
|
190
190
|
# "Favorites" has been deprecated by YouTube in favor of "Liked Videos".
|
191
|
-
channel = Yt::Channel.new
|
191
|
+
channel = Yt::Channel.new url: 'youtube.com/liz'
|
192
192
|
channel.related_playlists.find{|p| p.title == 'Favorites'}
|
193
193
|
```
|
194
194
|
|
@@ -832,4 +832,4 @@ TODO
|
|
832
832
|
|
833
833
|
$ client.activity(user) #default current user
|
834
834
|
|
835
|
-
-->
|
835
|
+
-->
|
data/bin/yt
CHANGED
@@ -8,20 +8,13 @@ rescue LoadError
|
|
8
8
|
end
|
9
9
|
|
10
10
|
Yt.configuration.log_level = :debug
|
11
|
-
id = ARGV[1] || '
|
11
|
+
id = ARGV[1] || 'rdwz7QiG0lk'
|
12
12
|
|
13
13
|
case ARGV[0]
|
14
14
|
when 'info'
|
15
15
|
puts "Yt version #{Yt::VERSION}"
|
16
16
|
video = Yt::Video.new id: id
|
17
|
-
puts video.
|
18
|
-
when 'annotations'
|
19
|
-
video = Yt::Video.new id: id
|
20
|
-
count = video.annotations.size
|
21
|
-
puts "Video #{id} has #{count} #{'annotation'.pluralize count}"
|
22
|
-
video.annotations.each.with_index do |annotation, i|
|
23
|
-
puts "#{i+1}) #{annotation.text}"
|
24
|
-
end
|
17
|
+
puts video.title
|
25
18
|
when 'video'
|
26
19
|
video = Yt::Video.new id: id
|
27
20
|
views = "#{video.view_count} #{'view'.pluralize video.view_count}"
|
data/lib/yt.rb
CHANGED
@@ -13,7 +13,6 @@ require 'yt/models/video_group'
|
|
13
13
|
require 'yt/models/comment_thread'
|
14
14
|
require 'yt/models/ownership'
|
15
15
|
require 'yt/models/advertising_options_set'
|
16
|
-
require 'yt/models/url'
|
17
16
|
|
18
17
|
# An object-oriented Ruby client for YouTube.
|
19
18
|
# Helps creating applications that need to interact with YouTube objects.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'yt/request'
|
2
|
+
|
3
|
+
module Yt
|
4
|
+
module Actions
|
5
|
+
module Get
|
6
|
+
include Base
|
7
|
+
|
8
|
+
def get
|
9
|
+
response = get_request(get_params).run
|
10
|
+
@data.merge! response.body
|
11
|
+
self
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_request(params = {})
|
17
|
+
@list_request = Yt::Request.new(params).tap do |request|
|
18
|
+
print "#{request.as_curl}\n" if Yt.configuration.developing?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_params
|
23
|
+
{}.tap do |params|
|
24
|
+
params[:method] = :get
|
25
|
+
params[:host] = 'www.googleapis.com'
|
26
|
+
params[:auth] = @auth
|
27
|
+
params[:exptected_response] = Net::HTTPOK
|
28
|
+
params[:api_key] = Yt.configuration.api_key if Yt.configuration.api_key
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -10,7 +10,7 @@ module Yt
|
|
10
10
|
# @option options [Array<Symbol>] :only The metrics to generate reports
|
11
11
|
# for.
|
12
12
|
# @option options [Symbol] :by (:day) The dimension to collect metrics
|
13
|
-
# by. Accepted values are: +:day+, +:
|
13
|
+
# by. Accepted values are: +:day+, +:month+.
|
14
14
|
# @option options [#to_date] :since The first day of the time-range.
|
15
15
|
# Also aliased as +:from+.
|
16
16
|
# @option options [#to_date] :until The last day of the time-range.
|
@@ -40,11 +40,6 @@ module Yt
|
|
40
40
|
# @example Get the $1 for this and last month:
|
41
41
|
# resource.$1 since: 1.month.ago, by: :month
|
42
42
|
# # => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}
|
43
|
-
# @return [Hash<Range<Date, Date>, $2>] if grouped by week, the $1
|
44
|
-
# for each week in the time-range.
|
45
|
-
# @example Get the $1 for this and last week:
|
46
|
-
# resource.$1 since: 1.week.ago, by: :week
|
47
|
-
# # => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}
|
48
43
|
# @macro report
|
49
44
|
|
50
45
|
# @!macro [new] report_with_range
|
@@ -75,19 +70,19 @@ module Yt
|
|
75
70
|
|
76
71
|
# @!macro [new] report_by_day
|
77
72
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
78
|
-
# Accepted values are: +:day+, +:
|
73
|
+
# Accepted values are: +:day+, +:month+.
|
79
74
|
# @macro report_with_day
|
80
75
|
|
81
76
|
# @!macro [new] report_by_day_and_country
|
82
77
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
83
|
-
# Accepted values are: +:day+, +:
|
78
|
+
# Accepted values are: +:day+, +:month+, :+range+.
|
84
79
|
# @macro report_with_day
|
85
80
|
# @macro report_with_range
|
86
81
|
# @macro report_with_country
|
87
82
|
|
88
83
|
# @!macro [new] report_by_day_and_state
|
89
84
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
90
|
-
# Accepted values are: +:day+, +:
|
85
|
+
# Accepted values are: +:day+, +:month+, :+range+.
|
91
86
|
# @macro report_with_day
|
92
87
|
# @macro report_with_range
|
93
88
|
# @macro report_with_country_and_state
|
@@ -128,7 +123,7 @@ module Yt
|
|
128
123
|
|
129
124
|
# @!macro [new] report_by_video_dimensions
|
130
125
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
131
|
-
# Accepted values are: +:day+, +:
|
126
|
+
# Accepted values are: +:day+, +:month+, +:range+,
|
132
127
|
# +:traffic_source+,+:search_term+, +:playback_location+,
|
133
128
|
# +:related_video+, +:embedded_player_location+.
|
134
129
|
# @option options [Array<Symbol>] :includes ([:id]) if grouped by
|
@@ -162,7 +157,7 @@ module Yt
|
|
162
157
|
|
163
158
|
# @!macro [new] report_by_channel_dimensions
|
164
159
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
165
|
-
# Accepted values are: +:day+, +:
|
160
|
+
# Accepted values are: +:day+, +:month+, +:range+,
|
166
161
|
# +:traffic_source+, +:search_term+, +:playback_location+, +:video+,
|
167
162
|
# +:related_video+, +:playlist+, +:embedded_player_location+.
|
168
163
|
# @return [Hash<Symbol, $2>] if grouped by embedded player location,
|
@@ -175,7 +170,7 @@ module Yt
|
|
175
170
|
|
176
171
|
# @!macro [new] report_by_playlist_dimensions
|
177
172
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
178
|
-
# Accepted values are: +:day+, +:
|
173
|
+
# Accepted values are: +:day+, +:month+, +:range+,
|
179
174
|
# +:traffic_source+, +:playback_location+, +:related_video+, +:video+,
|
180
175
|
# +:playlist+.
|
181
176
|
# @macro report_with_channel_dimensions
|
@@ -228,7 +223,7 @@ module Yt
|
|
228
223
|
def define_reports_method(metric, type)
|
229
224
|
(@metrics ||= {})[metric] = type
|
230
225
|
define_method :reports do |options = {}|
|
231
|
-
from = options[:since] || options[:from] || (options[:by].in?([:day, :
|
226
|
+
from = options[:since] || options[:from] || (options[:by].in?([:day, :month]) ? 5.days.ago : '2005-02-01')
|
232
227
|
to = options[:until] || options[:to] || Date.today
|
233
228
|
location = options[:in]
|
234
229
|
country = location.is_a?(Hash) ? location[:country] : location
|
@@ -252,7 +247,7 @@ module Yt
|
|
252
247
|
|
253
248
|
def define_metric_method(metric)
|
254
249
|
define_method metric do |options = {}|
|
255
|
-
from = options[:since] || options[:from] || (options[:by].in?([:day, :
|
250
|
+
from = options[:since] || options[:from] || (options[:by].in?([:day, :month]) ? 5.days.ago : '2005-02-01')
|
256
251
|
to = options[:until] || options[:to] || Date.today
|
257
252
|
location = options[:in]
|
258
253
|
country = location.is_a?(Hash) ? location[:country] : location
|
@@ -11,6 +11,7 @@ module Yt
|
|
11
11
|
underscore_keys! attributes
|
12
12
|
body = attributes.slice :asset_id, :video_id, :content_type, :policy
|
13
13
|
body[:policy] = {id: attributes[:policy_id]} if attributes[:policy_id]
|
14
|
+
body[:match_info] = match_attributes(attributes[:match_info]) if attributes[:match_info]
|
14
15
|
params = attributes.slice(:is_manual_claim).merge({on_behalf_of_content_owner: @auth.owner_name})
|
15
16
|
do_insert(params: params, body: body)
|
16
17
|
end
|
@@ -38,6 +39,13 @@ module Yt
|
|
38
39
|
super
|
39
40
|
end
|
40
41
|
|
42
|
+
def match_attributes(attributes = {})
|
43
|
+
segments = attributes[:match_segments].map do |segment|
|
44
|
+
{ manual_segment: (segment[:manual_segment] || segment).slice(:start, :finish) }
|
45
|
+
end
|
46
|
+
{ matchSegments: segments }
|
47
|
+
end
|
48
|
+
|
41
49
|
# @return [Hash] the parameters to submit to YouTube to list claims
|
42
50
|
# administered by the content owner.
|
43
51
|
# @see https://developers.google.com/youtube/partner/docs/v1/claims/list
|