yt 0.32.4 → 0.33.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -4
- data/CHANGELOG.md +43 -2
- data/README.md +22 -33
- data/YOUTUBE_IT.md +4 -4
- data/bin/yt +2 -9
- data/lib/yt.rb +0 -1
- data/lib/yt/actions/list.rb +1 -1
- data/lib/yt/associations/has_reports.rb +9 -14
- data/lib/yt/collections/playlist_items.rb +10 -1
- data/lib/yt/collections/reports.rb +5 -7
- data/lib/yt/models/account.rb +21 -1
- data/lib/yt/models/asset.rb +10 -1
- data/lib/yt/models/channel.rb +2 -5
- data/lib/yt/models/content_owner.rb +20 -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 +69 -3
- 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 +5 -2
- metadata +31 -169
- data/spec/collections/claims_spec.rb +0 -62
- 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 -32
- 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/configuration_spec.rb +0 -44
- 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 -143
- 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 -31
- 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/claim_spec.rb +0 -17
- data/spec/requests/as_content_owner/content_owner_spec.rb +0 -370
- 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: '070338f88a83b93cdef2c6dfb529f06c15da00bbd8c6fba10f1f98689bf40c7c'
|
4
|
+
data.tar.gz: 298b85fb4bef72439425838c594ebf546f65cff2070d379a9b6a756ff01155fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21fa9971e3d7cb96ecbe373d145c79cd8e665b2ea54acf3869674d0d4745d92e1d0cee7c34fad882670bf229a8833056cfe7bd77da60f1a7cadf4a05281c5af0
|
7
|
+
data.tar.gz: a26557d3e1b563f840f17f07ea6a61bb5b5820a018a2a8dcacb205cd00665304b82bce67af495177ef2c19b84734c0c8194cf7c4ae0c37d2afffe440e765d9bf
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,47 @@ 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.2 - 2020-11-11
|
10
|
+
|
11
|
+
* [BUGFIX] No more pages when page token is an empty string, per YouTube change.
|
12
|
+
|
13
|
+
## 0.33.1 - 2020-10-19
|
14
|
+
|
15
|
+
* [BUGFIX] Only retry once when exchanging a refresh token
|
16
|
+
|
17
|
+
## 0.33.0 - 2020-04-10
|
18
|
+
|
19
|
+
If your code calls reports methods such as `views`, `likes`, or `reports`,
|
20
|
+
do not include `by: :week` option since `7DayTotals` dimension will no longer be
|
21
|
+
supported by YouTube API as of [April 15, 2020](https://developers.google.com/youtube/analytics/revision_history#october-15,-2019).
|
22
|
+
|
23
|
+
Use `by: :day` option instead and add up the numbers from each day.
|
24
|
+
|
25
|
+
If you keep using `by: :week` option after this change it will raise an error
|
26
|
+
(before the gem upgrade) or it will run with `day` dimension instead (after
|
27
|
+
the gem upgrade, like any other random input).
|
28
|
+
|
29
|
+
* [REMOVAL] Remove `by: :week` option for reports.
|
30
|
+
* [FEATURE] Add back the option of initializing a resource by its URL.
|
31
|
+
* [BUGFIX] Limit retries on refreshing tokens
|
32
|
+
|
33
|
+
**Breaking change**
|
34
|
+
|
35
|
+
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`.
|
36
|
+
|
37
|
+
## 0.32.6 - 2020-02-07
|
38
|
+
|
39
|
+
* [FEATURE] Allow partnered channels to delete playlist item.
|
40
|
+
* [FEATURE] Allow partnered channels to update video.
|
41
|
+
* [FEATURE] Allow partnered channels to update playlist.
|
42
|
+
* [FEATURE] Allow partnered channels to upload thumbnail.
|
43
|
+
* [FEATURE] Allow partnered channels to create playlist item.
|
44
|
+
|
45
|
+
## 0.32.5 - 2019-11-06
|
46
|
+
|
47
|
+
* [BUGFIX] Fix `MatchPolicy#update` and `Asset#update` by using `PUT` instead of `PATCH`
|
48
|
+
* Update `bin/yt` file to keep `yt info` command work
|
49
|
+
|
9
50
|
## 0.32.4 - 2019-06-26
|
10
51
|
|
11
52
|
* [FEATURE] Add `ownership_effective` method to access asset ownership ("effective") via the asset object.
|
@@ -457,11 +498,11 @@ If your code expects reports to return results **by day** then you **must** add
|
|
457
498
|
the `by: :day` option to your report method. The new default is `by: :range`.
|
458
499
|
For instance `channel.views` would return
|
459
500
|
|
460
|
-
|
501
|
+
{Wed, 8 May 2014 => 12.4, Thu, 9 May 2014 => 3.2, Fri, 10 May 2014 => …}
|
461
502
|
|
462
503
|
and now returns the same as calling `channel.views by: :range`:
|
463
504
|
|
464
|
-
|
505
|
+
{total: 3450}
|
465
506
|
|
466
507
|
Additionally, if you expect reports **by day** then you **must** specify the
|
467
508
|
`:since` option to your report method. Previously, this value was set to
|
data/README.md
CHANGED
@@ -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
|
|
@@ -526,44 +525,34 @@ If a variable is set in both places, then `Yt.configure` takes precedence.
|
|
526
525
|
How to test
|
527
526
|
===========
|
528
527
|
|
529
|
-
|
530
|
-
|
531
|
-
1. tests in `spec/models`, `spec/collections` and `spec/errors` **do not hit** the YouTube API
|
532
|
-
1. tests in `spec/requests` **hit** the YouTube API and require authentication
|
533
|
-
|
534
|
-
To only run tests against models, collections and errors (which do not hit the API), type:
|
528
|
+
To run tests:
|
535
529
|
|
536
530
|
```bash
|
537
|
-
rspec
|
531
|
+
rspec
|
538
532
|
```
|
539
533
|
|
540
|
-
|
534
|
+
We recommend RSpec >= 3.8.
|
541
535
|
|
542
|
-
|
543
|
-
|
544
|
-
|
536
|
+
Yt comes with two different sets of tests:
|
537
|
+
|
538
|
+
1. Unit tests in `spec/models`, `spec/collections` and `spec/errors`
|
539
|
+
2. Legacy integration tests in `spec/requests`
|
540
|
+
|
541
|
+
Coming soon will be a new set of high-level integration tests.
|
542
|
+
|
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.
|
548
|
+
|
549
|
+
Some of the integration tests require authentication. These can be set
|
550
|
+
with the following environment variables:
|
545
551
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
* Account-based tests, which require a valid refresh token along with
|
552
|
-
the application-level credentials the refresh token was created with
|
553
|
-
(`YT_TEST_DEVICE_REFRESH_TOKEN`, `YT_TEST_DEVICE_CLIENT_ID`, and
|
554
|
-
`YT_TEST_DEVICE_CLIENT_SECRET` respectively).
|
555
|
-
* Server application tests, which use a server API key
|
556
|
-
(`YT_TEST_SERVER_API_KEY`).
|
557
|
-
* Tests that excercise YouTube's partner functionality. This requires an
|
558
|
-
a partner channel id (`YT_TEST_CONTENT_OWNER_NAME`), a refresh token
|
559
|
-
that's authenticated with that channel
|
560
|
-
(`YT_TEST_CONTENT_OWNER_REFRESH_TOKEN`), and the corresponding
|
561
|
-
application (`YT_TEST_PARTNER_CLIENT_ID` and
|
562
|
-
(`YT_TEST_PARTNER_CLIENT_SECRET`).
|
563
|
-
|
564
|
-
The refresh tokens need to be generated with the `youtube`,
|
565
|
-
`yt-analytics` and `userinfo.profile` permissions in order for tests to
|
566
|
-
pass.
|
552
|
+
* `YT_TEST_CLIENT_ID`
|
553
|
+
* `YT_TEST_CLIENT_SECRET`
|
554
|
+
* `YT_TEST_API_KEY`
|
555
|
+
* `YT_TEST_REFRESH_TOKEN`
|
567
556
|
|
568
557
|
How to release new versions
|
569
558
|
===========================
|
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.
|
data/lib/yt/actions/list.rb
CHANGED
@@ -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
|
@@ -48,6 +48,15 @@ module Yt
|
|
48
48
|
def insert_parts
|
49
49
|
{snippet: {keys: [:playlist_id, :resource_id, :position]}}
|
50
50
|
end
|
51
|
+
|
52
|
+
# For inserting a playlist item with content owner auth.
|
53
|
+
# @see https://developers.google.com/youtube/v3/docs/playlistItems/insert
|
54
|
+
def insert_params
|
55
|
+
params = super
|
56
|
+
params[:params] ||= {}
|
57
|
+
params[:params].merge! @auth.insert_playlist_item_params
|
58
|
+
params
|
59
|
+
end
|
51
60
|
end
|
52
61
|
end
|
53
|
-
end
|
62
|
+
end
|
@@ -6,7 +6,6 @@ module Yt
|
|
6
6
|
class Reports < Base
|
7
7
|
DIMENSIONS = Hash.new({name: 'day', parse: ->(day, *values) { @metrics.keys.zip(values.map{|v| {Date.iso8601(day) => v}}).to_h} }).tap do |hash|
|
8
8
|
hash[:month] = {name: 'month', parse: ->(month, *values) { @metrics.keys.zip(values.map{|v| {Range.new(Date.strptime(month, '%Y-%m').beginning_of_month, Date.strptime(month, '%Y-%m').end_of_month) => v} }).to_h} }
|
9
|
-
hash[:week] = {name: '7DayTotals', parse: ->(last_day_of_week, *values) { @metrics.keys.zip(values.map{|v| {Range.new(Date.strptime(last_day_of_week) - 6, Date.strptime(last_day_of_week)) => v} }).to_h} }
|
10
9
|
hash[:range] = {parse: ->(*values) { @metrics.keys.zip(values.map{|v| {total: v}}).to_h } }
|
11
10
|
hash[:traffic_source] = {name: 'insightTrafficSourceType', parse: ->(source, *values) { @metrics.keys.zip(values.map{|v| {TRAFFIC_SOURCES.key(source) => v}}).to_h} }
|
12
11
|
hash[:playback_location] = {name: 'insightPlaybackLocationType', parse: ->(location, *values) { @metrics.keys.zip(values.map{|v| {PLAYBACK_LOCATIONS.key(location) => v}}).to_h} }
|
@@ -140,11 +139,6 @@ module Yt
|
|
140
139
|
end
|
141
140
|
if dimension == :month
|
142
141
|
hash = hash.transform_values{|h| h.sort_by{|range, v| range.first}.to_h}
|
143
|
-
elsif dimension == :week
|
144
|
-
hash = hash.transform_values do |h|
|
145
|
-
h.select{|range, v| range.last.wday == days_range.last.wday}.
|
146
|
-
sort_by{|range, v| range.first}.to_h
|
147
|
-
end
|
148
142
|
elsif dimension == :day
|
149
143
|
hash = hash.transform_values{|h| h.sort_by{|day, v| day}.to_h}
|
150
144
|
elsif dimension.in? [:traffic_source, :country, :state, :playback_location, :device_type, :operating_system, :subscribed_status]
|
@@ -159,11 +153,15 @@ module Yt
|
|
159
153
|
# same query is a workaround that works and can hardly cause any damage.
|
160
154
|
# Similarly, once in while YouTube responds with a random 503 error.
|
161
155
|
rescue Yt::Error => e
|
162
|
-
(max_retries > 0) && rescue?(e) ? sleep(
|
156
|
+
(max_retries > 0) && rescue?(e) ? sleep(retry_time) && within(days_range, country, state, dimension, videos, historical, max_retries - 1) : raise
|
163
157
|
end
|
164
158
|
|
165
159
|
private
|
166
160
|
|
161
|
+
def retry_time
|
162
|
+
3
|
163
|
+
end
|
164
|
+
|
167
165
|
def type_cast(value, type)
|
168
166
|
case [type]
|
169
167
|
when [Integer] then value.to_i if value
|
data/lib/yt/models/account.rb
CHANGED
@@ -65,7 +65,7 @@ module Yt
|
|
65
65
|
# @param [Hash] params the metadata to add to the uploaded video.
|
66
66
|
# @option params [String] :title The video’s title.
|
67
67
|
# @option params [String] :description The video’s description.
|
68
|
-
# @option params [Array<String>] :
|
68
|
+
# @option params [Array<String>] :tags The video’s tags.
|
69
69
|
# @option params [String] :privacy_status The video’s privacy status.
|
70
70
|
# @return [Yt::Models::Video] the newly uploaded video.
|
71
71
|
def upload_video(path_or_url, params = {})
|
@@ -192,6 +192,10 @@ module Yt
|
|
192
192
|
{mine: true}
|
193
193
|
end
|
194
194
|
|
195
|
+
def playlist_items_params
|
196
|
+
{}
|
197
|
+
end
|
198
|
+
|
195
199
|
# @private
|
196
200
|
# Tells `has_many :resumable_sessions` what path to hit to upload a file.
|
197
201
|
def upload_path
|
@@ -223,6 +227,22 @@ module Yt
|
|
223
227
|
def upload_content_type
|
224
228
|
'video/*'
|
225
229
|
end
|
230
|
+
|
231
|
+
def update_video_params
|
232
|
+
{}
|
233
|
+
end
|
234
|
+
|
235
|
+
def update_playlist_params
|
236
|
+
{}
|
237
|
+
end
|
238
|
+
|
239
|
+
def upload_thumbnail_params
|
240
|
+
{}
|
241
|
+
end
|
242
|
+
|
243
|
+
def insert_playlist_item_params
|
244
|
+
{}
|
245
|
+
end
|
226
246
|
end
|
227
247
|
end
|
228
248
|
end
|
data/lib/yt/models/asset.rb
CHANGED
@@ -17,7 +17,7 @@ module Yt
|
|
17
17
|
|
18
18
|
def update(attributes = {})
|
19
19
|
underscore_keys! attributes
|
20
|
-
|
20
|
+
do_update body: attributes
|
21
21
|
true
|
22
22
|
end
|
23
23
|
|
@@ -112,6 +112,15 @@ module Yt
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
# @see https://developers.google.com/youtube/partner/docs/v1/assets/update
|
116
|
+
def update_params
|
117
|
+
super.tap do |params|
|
118
|
+
params[:expected_response] = Net::HTTPOK
|
119
|
+
params[:path] = "/youtube/partner/v1/assets/#{@id}"
|
120
|
+
params[:params] = {on_behalf_of_content_owner: @auth.owner_name}
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
115
124
|
# @return [Hash] the parameters to submit to YouTube to get an asset.
|
116
125
|
# @see https://developers.google.com/youtube/partner/docs/v1/assets/get
|
117
126
|
def get_params
|
data/lib/yt/models/channel.rb
CHANGED
@@ -197,10 +197,6 @@ module Yt
|
|
197
197
|
# @return [Integer] the number of times the channel has been viewed.
|
198
198
|
delegate :view_count, to: :statistics_set
|
199
199
|
|
200
|
-
# @!attribute [r] comment_count
|
201
|
-
# @return [Integer] the number of comments for the channel.
|
202
|
-
delegate :comment_count, to: :statistics_set
|
203
|
-
|
204
200
|
# @!attribute [r] video_count
|
205
201
|
# @return [Integer] the number of videos uploaded to the channel.
|
206
202
|
delegate :video_count, to: :statistics_set
|
@@ -283,7 +279,8 @@ module Yt
|
|
283
279
|
# @private
|
284
280
|
# Tells `has_reports` to retrieve the reports from YouTube Analytics API
|
285
281
|
# either as a Channel or as a Content Owner.
|
286
|
-
# @see https://developers.google.com/youtube/analytics/
|
282
|
+
# @see https://developers.google.com/youtube/analytics/channel_reports
|
283
|
+
# @see https://developers.google.com/youtube/analytics/content_owner_reports
|
287
284
|
def reports_params
|
288
285
|
{}.tap do |params|
|
289
286
|
if auth.owner_name
|