yt 0.21.0 → 0.22.0
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 +4 -4
- data/.yardopts +1 -0
- data/CHANGELOG.md +13 -0
- data/README.md +8 -461
- data/lib/yt/actions/base.rb +1 -0
- data/lib/yt/associations/has_attribute.rb +2 -0
- data/lib/yt/associations/has_authentication.rb +2 -0
- data/lib/yt/associations/has_many.rb +1 -0
- data/lib/yt/associations/has_one.rb +1 -0
- data/lib/yt/associations/has_reports.rb +24 -18
- data/lib/yt/collections/authentications.rb +1 -0
- data/lib/yt/collections/content_details.rb +1 -0
- data/lib/yt/collections/content_owner_details.rb +1 -0
- data/lib/yt/collections/file_details.rb +1 -0
- data/lib/yt/collections/ids.rb +1 -0
- data/lib/yt/collections/live_streaming_details.rb +1 -0
- data/lib/yt/collections/players.rb +1 -0
- data/lib/yt/collections/ratings.rb +1 -0
- data/lib/yt/collections/reports.rb +25 -16
- data/lib/yt/collections/resources.rb +1 -0
- data/lib/yt/collections/resumable_sessions.rb +1 -0
- data/lib/yt/collections/snippets.rb +1 -0
- data/lib/yt/collections/statistics_sets.rb +1 -0
- data/lib/yt/collections/statuses.rb +1 -0
- data/lib/yt/collections/subscriptions.rb +1 -0
- data/lib/yt/collections/user_infos.rb +1 -0
- data/lib/yt/models/account.rb +28 -26
- data/lib/yt/models/base.rb +1 -0
- data/lib/yt/models/channel.rb +38 -38
- data/lib/yt/models/content_detail.rb +1 -0
- data/lib/yt/models/content_owner_detail.rb +1 -0
- data/lib/yt/models/device_flow.rb +1 -0
- data/lib/yt/models/file_detail.rb +1 -0
- data/lib/yt/models/iterator.rb +1 -0
- data/lib/yt/models/live_streaming_detail.rb +1 -0
- data/lib/yt/models/player.rb +1 -0
- data/lib/yt/models/playlist.rb +19 -19
- data/lib/yt/models/playlist_item.rb +12 -12
- data/lib/yt/models/rating.rb +1 -0
- data/lib/yt/models/resource.rb +8 -2
- data/lib/yt/models/resumable_session.rb +1 -0
- data/lib/yt/models/snippet.rb +1 -0
- data/lib/yt/models/statistics_set.rb +1 -0
- data/lib/yt/models/status.rb +1 -6
- data/lib/yt/models/subscription.rb +1 -0
- data/lib/yt/models/timestamp.rb +1 -0
- data/lib/yt/models/url.rb +1 -0
- data/lib/yt/models/user_info.rb +1 -0
- data/lib/yt/models/video.rb +70 -70
- data/lib/yt/models/video_category.rb +1 -0
- data/lib/yt/request.rb +1 -0
- data/lib/yt/version.rb +1 -1
- data/spec/collections/reports_spec.rb +1 -1
- data/spec/requests/as_content_owner/channel_spec.rb +210 -14
- data/spec/requests/as_content_owner/playlist_spec.rb +68 -8
- data/spec/requests/as_content_owner/video_spec.rb +213 -16
- data/spec/requests/as_server_app/channel_spec.rb +27 -7
- data/spec/requests/as_server_app/playlist_spec.rb +25 -4
- data/spec/requests/as_server_app/video_spec.rb +26 -5
- metadata +1 -3
- data/spec/requests/as_server_app/resource_spec.rb +0 -46
@@ -13,11 +13,16 @@ module Yt
|
|
13
13
|
# Also aliased as +:to+.
|
14
14
|
|
15
15
|
# @!macro [new] report_with_day
|
16
|
-
# @return [Hash<Date,
|
16
|
+
# @return [Hash<Date, $2>] if grouped by day, the $1
|
17
17
|
# for each day in the time-range.
|
18
18
|
# @example Get the $1 for each day of last week:
|
19
19
|
# resource.$1 since: 2.weeks.ago, until: 1.week.ago, by: :day
|
20
20
|
# # => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.2, …}
|
21
|
+
# @return [Hash<Symbol, $2>] if grouped by range, the $1
|
22
|
+
# for the entire time-range (under the key +:total+).
|
23
|
+
# @example Get the $1 for the whole last week:
|
24
|
+
# resource.$1 since: 2.weeks.ago, until: 1.week.ago, by: :range
|
25
|
+
# # => {Wed, 8 May 2014..Tue, 14 May 2014 => 564.0,}
|
21
26
|
# @macro report
|
22
27
|
|
23
28
|
# @!macro [new] report_by_day
|
@@ -26,22 +31,22 @@ module Yt
|
|
26
31
|
# @macro report_with_day
|
27
32
|
|
28
33
|
# @!macro [new] report_with_video_dimensions
|
29
|
-
# @return [Hash<Symbol,
|
34
|
+
# @return [Hash<Symbol, $2>] if grouped by playback location, the
|
30
35
|
# $1 for each traffic playback location.
|
31
36
|
# @example Get yesterday’s $1 grouped by playback location:
|
32
37
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :playback_location
|
33
38
|
# # => {embedded: 53.0, watch: 467.0, …}
|
34
|
-
# @return [Hash<Yt::Video,
|
39
|
+
# @return [Hash<Yt::Video, $2>] if grouped by related video, the
|
35
40
|
# $1 for each related video.
|
36
41
|
# @example Get yesterday’s $1 by related video:
|
37
42
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :related_video
|
38
43
|
# # => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}
|
39
|
-
# @return [Hash<Yt::Video,
|
44
|
+
# @return [Hash<Yt::Video, $2>] if grouped by device type, the
|
40
45
|
# $1 for each device type.
|
41
46
|
# @example Get yesterday’s $1 by device type:
|
42
47
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :device_type
|
43
48
|
# # => {mobile: 133.0, tv: 412.0, …}
|
44
|
-
# @return [Hash<Yt::Video,
|
49
|
+
# @return [Hash<Yt::Video, $2>] if grouped by traffic source, the
|
45
50
|
# $1 for each traffic source.
|
46
51
|
# @example Get yesterday’s $1 by traffic source:
|
47
52
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :traffic_source
|
@@ -52,7 +57,7 @@ module Yt
|
|
52
57
|
# @option options [Symbol] :by (:day) The dimension to collect $1 by.
|
53
58
|
# Accepted values are: +:day+, +:traffic_source+,
|
54
59
|
# +:playback_location+, +:related_video+, +:embedded_player_location+.
|
55
|
-
# @return [Hash<Symbol,
|
60
|
+
# @return [Hash<Symbol, $2>] if grouped by embedded player location,
|
56
61
|
# the $1 for each embedded player location.
|
57
62
|
# @example Get yesterday’s $1 by embedded player location:
|
58
63
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :embedded_player_location
|
@@ -60,12 +65,12 @@ module Yt
|
|
60
65
|
# @macro report_with_video_dimensions
|
61
66
|
|
62
67
|
# @!macro [new] report_with_channel_dimensions
|
63
|
-
# @return [Hash<Yt::Video,
|
68
|
+
# @return [Hash<Yt::Video, $2>] if grouped by video, the
|
64
69
|
# $1 for each video.
|
65
70
|
# @example Get yesterday’s $1 by video:
|
66
71
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :video
|
67
72
|
# # => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}
|
68
|
-
# @return [Hash<Yt::Video,
|
73
|
+
# @return [Hash<Yt::Video, $2>] if grouped by playlist, the
|
69
74
|
# $1 for each playlist.
|
70
75
|
# @example Get yesterday’s $1 by playlist:
|
71
76
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :playlist
|
@@ -77,7 +82,7 @@ module Yt
|
|
77
82
|
# Accepted values are: +:day+, +:traffic_source+,
|
78
83
|
# +:playback_location+, +:related_video+, +:video+,
|
79
84
|
# +:playlist+, +:embedded_player_location+.
|
80
|
-
# @return [Hash<Symbol,
|
85
|
+
# @return [Hash<Symbol, $2>] if grouped by embedded player location,
|
81
86
|
# the $1 for each embedded player location.
|
82
87
|
# @example Get yesterday’s $1 by embedded player location:
|
83
88
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :embedded_player_location
|
@@ -95,17 +100,17 @@ module Yt
|
|
95
100
|
# @option options [Symbol] :by (:gender_age_group) The dimension to
|
96
101
|
# show viewer percentage by.
|
97
102
|
# Accepted values are: +:gender+, +:age_group+, +:gender_age_group+.
|
98
|
-
# @return [Hash<Symbol,
|
103
|
+
# @return [Hash<Symbol, $2>] if grouped by gender, the
|
99
104
|
# viewer percentage by gender.
|
100
105
|
# @example Get yesterday’s viewer percentage by gender:
|
101
106
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :gender
|
102
107
|
# # => {female: 53.0, male: 47.0}
|
103
|
-
# @return [Hash<String,
|
108
|
+
# @return [Hash<String, $2>] if grouped by age group, the
|
104
109
|
# viewer percentage by age group.
|
105
110
|
# @example Get yesterday’s $1 grouped by age group:
|
106
111
|
# resource.$1 from: 1.day.ago, to: 1.day.ago, by: :age_group
|
107
112
|
# # => {"18-24" => 4.54, "35-24" => 12.31, "45-34" => 8.92, …}
|
108
|
-
# @return [Hash<Symbol, [Hash<String,
|
113
|
+
# @return [Hash<Symbol, [Hash<String, $2>]>] if grouped by gender
|
109
114
|
# and age group, the viewer percentage by gender/age group.
|
110
115
|
# @example Get yesterday’s $1 by gender and age group:
|
111
116
|
# resource.$1 from: 1.day.ago, to: 1.day.ago
|
@@ -115,16 +120,17 @@ module Yt
|
|
115
120
|
# Defines two public instance methods to access the reports of a
|
116
121
|
# resource for a specific metric.
|
117
122
|
# @param [Symbol] metric the metric to access the reports of.
|
118
|
-
# @
|
123
|
+
# @param [Class] type The class to cast the returned values to.
|
124
|
+
# @example Adds +comments+ and +comments_on+ on a Channel resource.
|
119
125
|
# class Channel < Resource
|
120
|
-
# has_report :
|
126
|
+
# has_report :comments, Integer
|
121
127
|
# end
|
122
|
-
def has_report(metric)
|
128
|
+
def has_report(metric, type)
|
123
129
|
require 'yt/collections/reports'
|
124
130
|
|
125
131
|
define_metric_on_method metric
|
126
132
|
define_metric_method metric
|
127
|
-
define_range_metric_method metric
|
133
|
+
define_range_metric_method metric, type
|
128
134
|
define_all_metric_method metric
|
129
135
|
end
|
130
136
|
|
@@ -157,11 +163,11 @@ module Yt
|
|
157
163
|
end
|
158
164
|
end
|
159
165
|
|
160
|
-
def define_range_metric_method(metric)
|
166
|
+
def define_range_metric_method(metric, type)
|
161
167
|
define_method "range_#{metric}" do |date_range, dimension|
|
162
168
|
ivar = instance_variable_get "@range_#{metric}_#{dimension}"
|
163
169
|
instance_variable_set "@range_#{metric}_#{dimension}", ivar || {}
|
164
|
-
instance_variable_get("@range_#{metric}_#{dimension}")[date_range] ||= send("all_#{metric}").within date_range, dimension
|
170
|
+
instance_variable_get("@range_#{metric}_#{dimension}")[date_range] ||= send("all_#{metric}").within date_range, dimension, type
|
165
171
|
end
|
166
172
|
private "range_#{metric}"
|
167
173
|
end
|
data/lib/yt/collections/ids.rb
CHANGED
@@ -2,18 +2,20 @@ require 'yt/collections/base'
|
|
2
2
|
|
3
3
|
module Yt
|
4
4
|
module Collections
|
5
|
+
# @private
|
5
6
|
class Reports < Base
|
6
|
-
DIMENSIONS = Hash.new({name: 'day', parse: ->(day) {Date.iso8601
|
7
|
-
hash[:
|
8
|
-
hash[:
|
9
|
-
hash[:
|
10
|
-
hash[:
|
11
|
-
hash[:
|
12
|
-
hash[:
|
13
|
-
hash[:
|
14
|
-
hash[:
|
15
|
-
hash[:
|
16
|
-
hash[:
|
7
|
+
DIMENSIONS = Hash.new({name: 'day', parse: ->(day, *values) {[Date.iso8601(day), values.last]} }).tap do |hash|
|
8
|
+
hash[:range] = {parse: ->(*values) { [:total, values.last]} }
|
9
|
+
hash[:traffic_source] = {name: 'insightTrafficSourceType', parse: ->(source, value) {[TRAFFIC_SOURCES.key(source), value]} }
|
10
|
+
hash[:playback_location] = {name: 'insightPlaybackLocationType', parse: ->(location, value) {[PLAYBACK_LOCATIONS.key(location), value]} }
|
11
|
+
hash[:embedded_player_location] = {name: 'insightPlaybackLocationDetail', parse: ->(url, value) {[url, value]} }
|
12
|
+
hash[:related_video] = {name: 'insightTrafficSourceDetail', parse: ->(video_id, value) { [Yt::Video.new(id: video_id, auth: @auth), value] } }
|
13
|
+
hash[:video] = {name: 'video', parse: ->(video_id, value) { [Yt::Video.new(id: video_id, auth: @auth), value] } }
|
14
|
+
hash[:playlist] = {name: 'playlist', parse: ->(playlist_id, value) { [Yt::Playlist.new(id: playlist_id, auth: @auth), value] } }
|
15
|
+
hash[:device_type] = {name: 'deviceType', parse: ->(type, value) { [type.downcase.to_sym, value] } }
|
16
|
+
hash[:gender_age_group] = {name: 'gender,ageGroup', parse: ->(gender, *values) { [gender.downcase.to_sym, *values] }}
|
17
|
+
hash[:gender] = {name: 'gender', parse: ->(gender, value) { [gender.downcase.to_sym, value] } }
|
18
|
+
hash[:age_group] = {name: 'ageGroup', parse: ->(age_group, value) { [age_group[3..-1], value] } }
|
17
19
|
end
|
18
20
|
|
19
21
|
# @see https://developers.google.com/youtube/analytics/v1/dimsmets/dims#Traffic_Source_Dimensions
|
@@ -46,7 +48,7 @@ module Yt
|
|
46
48
|
|
47
49
|
attr_writer :metric
|
48
50
|
|
49
|
-
def within(days_range, dimension, try_again = true)
|
51
|
+
def within(days_range, dimension, type, try_again = true)
|
50
52
|
@days_range = days_range
|
51
53
|
@dimension = dimension
|
52
54
|
if dimension == :gender_age_group # array of array
|
@@ -54,7 +56,7 @@ module Yt
|
|
54
56
|
each{|gender, age_group, value| hash[gender][age_group[3..-1]] = value}
|
55
57
|
end
|
56
58
|
else
|
57
|
-
Hash[*flat_map{|value| [value.first, value.last]}]
|
59
|
+
Hash[*flat_map{|value| [value.first, type_cast(value.last, type)]}]
|
58
60
|
end
|
59
61
|
# NOTE: Once in a while, YouTube responds with 400 Error and the message
|
60
62
|
# "Invalid query. Query did not conform to the expectations."; in this
|
@@ -63,13 +65,20 @@ module Yt
|
|
63
65
|
# same query is a workaround that works and can hardly cause any damage.
|
64
66
|
# Similarly, once in while YouTube responds with a random 503 error.
|
65
67
|
rescue Yt::Error => e
|
66
|
-
try_again && rescue?(e) ? sleep(3) && within(days_range, dimension, false) : raise
|
68
|
+
try_again && rescue?(e) ? sleep(3) && within(days_range, dimension, type, false) : raise
|
67
69
|
end
|
68
70
|
|
69
71
|
private
|
70
72
|
|
73
|
+
def type_cast(value, type)
|
74
|
+
case [type]
|
75
|
+
when [Integer] then value.to_i if value
|
76
|
+
when [Float] then value.to_f if value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
71
80
|
def new_item(data)
|
72
|
-
|
81
|
+
instance_exec *data, &DIMENSIONS[@dimension][:parse]
|
73
82
|
end
|
74
83
|
|
75
84
|
# @see https://developers.google.com/youtube/analytics/v1/content_owner_reports
|
@@ -86,7 +95,7 @@ module Yt
|
|
86
95
|
params['start-date'] = @days_range.begin
|
87
96
|
params['end-date'] = @days_range.end
|
88
97
|
params['metrics'] = @metric.to_s.camelize(:lower)
|
89
|
-
params['dimensions'] = DIMENSIONS[@dimension][:name]
|
98
|
+
params['dimensions'] = DIMENSIONS[@dimension][:name] unless @dimension == :range
|
90
99
|
params['max-results'] = 10 if @dimension == :video
|
91
100
|
params['max-results'] = 200 if @dimension == :playlist
|
92
101
|
params['max-results'] = 25 if @dimension == :embedded_player_location
|
data/lib/yt/models/account.rb
CHANGED
@@ -12,11 +12,11 @@ module Yt
|
|
12
12
|
has_one :user_info
|
13
13
|
|
14
14
|
# @!attribute [r] id
|
15
|
-
#
|
15
|
+
# @return [String] the (Google+) account’s ID.
|
16
16
|
delegate :id, to: :user_info
|
17
17
|
|
18
18
|
# @!attribute [r] email
|
19
|
-
#
|
19
|
+
# @return [String] the account’s email address.
|
20
20
|
delegate :email, to: :user_info
|
21
21
|
|
22
22
|
# @return [Boolean] whether the email address is verified.
|
@@ -25,15 +25,15 @@ module Yt
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# @!attribute [r] name
|
28
|
-
#
|
28
|
+
# @return [String] the account’s full name.
|
29
29
|
delegate :name, to: :user_info
|
30
30
|
|
31
31
|
# @!attribute [r] given_name
|
32
|
-
#
|
32
|
+
# @return [String] the user’s given (first) name.
|
33
33
|
delegate :given_name, to: :user_info
|
34
34
|
|
35
35
|
# @!attribute [r] family_name
|
36
|
-
#
|
36
|
+
# @return [String] the user’s family (last) name.
|
37
37
|
delegate :family_name, to: :user_info
|
38
38
|
|
39
39
|
# @return [String] the URL of the account’s (Google +) profile page.
|
@@ -97,27 +97,29 @@ module Yt
|
|
97
97
|
playlists.insert params
|
98
98
|
end
|
99
99
|
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
100
|
+
# @!method delete_playlists(attributes = {})
|
101
|
+
# Deletes the account’s playlists matching all the given attributes.
|
102
|
+
# @return [Array<Boolean>] whether each playlist matching the given
|
103
|
+
# attributes was deleted.
|
104
|
+
# @param [Hash] attributes the attributes to match the playlists by.
|
105
|
+
# @option attributes [<String, Regexp>] :title The playlist’s title.
|
106
|
+
# Pass a String for perfect match or a Regexp for advanced match.
|
107
|
+
# @option attributes [<String, Regexp>] :description The playlist’s
|
108
|
+
# description. Pass a String (perfect match) or a Regexp (advanced).
|
109
|
+
# @option attributes [Array<String>] :tags The playlist’s tags.
|
110
|
+
# All tags must match exactly.
|
111
|
+
# @option attributes [String] :privacy_status The playlist’s privacy
|
112
|
+
# status.
|
112
113
|
delegate :delete_playlists, to: :channel
|
113
114
|
|
114
115
|
### CONTENT OWNERS ###
|
115
116
|
|
116
117
|
# @!attribute [r] content_owners
|
117
|
-
#
|
118
|
-
#
|
118
|
+
# @return [Yt::Collections::ContentOwners] the content owners that
|
119
|
+
# the account can manage.
|
119
120
|
has_many :content_owners
|
120
121
|
|
122
|
+
# The name of the content owner managing the account.
|
121
123
|
# @return [String] name of the CMS account, if the account is partnered.
|
122
124
|
# @return [nil] if the account is not a partnered content owner.
|
123
125
|
attr_reader :owner_name
|
@@ -125,16 +127,16 @@ module Yt
|
|
125
127
|
### ASSOCIATIONS ###
|
126
128
|
|
127
129
|
# @!attribute [r] channel
|
128
|
-
#
|
130
|
+
# @return [Yt::Models::Channel] the YouTube channel of the account.
|
129
131
|
has_one :channel
|
130
132
|
|
131
133
|
# @!attribute [r] playlists
|
132
|
-
#
|
134
|
+
# @return [Yt::Collections::Playlists] the playlists owned by the account.
|
133
135
|
delegate :playlists, to: :channel
|
134
136
|
|
135
137
|
# @!attribute [r] subscribed_channels
|
136
|
-
#
|
137
|
-
#
|
138
|
+
# @return [Yt::Collections::SubscribedChannels] the channels that the
|
139
|
+
# account is subscribed to.
|
138
140
|
delegate :subscribed_channels, to: :channel
|
139
141
|
|
140
142
|
# @!attribute [r] videos
|
@@ -142,12 +144,12 @@ module Yt
|
|
142
144
|
has_many :videos
|
143
145
|
|
144
146
|
# @!attribute [r] subscribers
|
145
|
-
#
|
146
|
-
#
|
147
|
+
# @return [Yt::Collections::Subscribers] the channels subscribed to
|
148
|
+
# the account’s channel.
|
147
149
|
has_many :subscribers
|
148
150
|
|
149
|
-
# @private
|
150
151
|
# @!attribute [r] resumable_sessions
|
152
|
+
# @private
|
151
153
|
# @return [Yt::Collections::ResumableSessions] the sessions used to
|
152
154
|
# upload videos using the resumable upload protocol.
|
153
155
|
has_many :resumable_sessions
|
data/lib/yt/models/base.rb
CHANGED
data/lib/yt/models/channel.rb
CHANGED
@@ -9,24 +9,24 @@ module Yt
|
|
9
9
|
### SNIPPET ###
|
10
10
|
|
11
11
|
# @!attribute [r] title
|
12
|
-
#
|
12
|
+
# @return [String] the channel’s title.
|
13
13
|
delegate :title, to: :snippet
|
14
14
|
|
15
15
|
# @!attribute [r] description
|
16
|
-
#
|
16
|
+
# @return [String] the channel’s description.
|
17
17
|
delegate :description, to: :snippet
|
18
18
|
|
19
|
-
# Returns the URL of the channel’s thumbnail.
|
20
19
|
# @!method thumbnail_url(size = :default)
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
20
|
+
# Returns the URL of the channel’s thumbnail.
|
21
|
+
# @param [Symbol, String] size The size of the channel’s thumbnail.
|
22
|
+
# @return [String] if +size+ is +default+, the URL of a 88x88px image.
|
23
|
+
# @return [String] if +size+ is +medium+, the URL of a 240x240px image.
|
24
|
+
# @return [String] if +size+ is +high+, the URL of a 800x800px image.
|
25
|
+
# @return [nil] if the +size+ is not +default+, +medium+ or +high+.
|
26
26
|
delegate :thumbnail_url, to: :snippet
|
27
27
|
|
28
28
|
# @!attribute [r] published_at
|
29
|
-
#
|
29
|
+
# @return [Time] the date and time that the channel was created.
|
30
30
|
delegate :published_at, to: :snippet
|
31
31
|
|
32
32
|
### SUBSCRIPTION ###
|
@@ -104,80 +104,80 @@ module Yt
|
|
104
104
|
### ANALYTICS ###
|
105
105
|
|
106
106
|
# @macro report_by_channel_dimensions
|
107
|
-
has_report :views
|
107
|
+
has_report :views, Integer
|
108
108
|
|
109
109
|
# @macro report_by_channel_dimensions
|
110
|
-
has_report :estimated_minutes_watched
|
110
|
+
has_report :estimated_minutes_watched, Float
|
111
111
|
|
112
112
|
# @macro report_by_gender_and_age_group
|
113
|
-
has_report :viewer_percentage
|
113
|
+
has_report :viewer_percentage, Float
|
114
114
|
|
115
115
|
# @macro report_by_day
|
116
|
-
has_report :comments
|
116
|
+
has_report :comments, Integer
|
117
117
|
|
118
118
|
# @macro report_by_day
|
119
|
-
has_report :likes
|
119
|
+
has_report :likes, Integer
|
120
120
|
|
121
121
|
# @macro report_by_day
|
122
|
-
has_report :dislikes
|
122
|
+
has_report :dislikes, Integer
|
123
123
|
|
124
124
|
# @macro report_by_day
|
125
|
-
has_report :shares
|
125
|
+
has_report :shares, Integer
|
126
126
|
|
127
127
|
# @macro report_by_day
|
128
|
-
has_report :subscribers_gained
|
128
|
+
has_report :subscribers_gained, Integer
|
129
129
|
|
130
130
|
# @macro report_by_day
|
131
|
-
has_report :subscribers_lost
|
131
|
+
has_report :subscribers_lost, Integer
|
132
132
|
|
133
133
|
# @macro report_by_day
|
134
|
-
has_report :favorites_added
|
134
|
+
has_report :favorites_added, Integer
|
135
135
|
|
136
136
|
# @macro report_by_day
|
137
|
-
has_report :favorites_removed
|
137
|
+
has_report :favorites_removed, Integer
|
138
138
|
|
139
139
|
# @macro report_by_day
|
140
|
-
has_report :average_view_duration
|
140
|
+
has_report :average_view_duration, Float
|
141
141
|
|
142
142
|
# @macro report_by_day
|
143
|
-
has_report :average_view_percentage
|
143
|
+
has_report :average_view_percentage, Float
|
144
144
|
|
145
145
|
# @macro report_by_day
|
146
|
-
has_report :annotation_clicks
|
146
|
+
has_report :annotation_clicks, Integer
|
147
147
|
|
148
148
|
# @macro report_by_day
|
149
|
-
has_report :annotation_click_through_rate
|
149
|
+
has_report :annotation_click_through_rate, Float
|
150
150
|
|
151
151
|
# @macro report_by_day
|
152
|
-
has_report :annotation_close_rate
|
152
|
+
has_report :annotation_close_rate, Float
|
153
153
|
|
154
154
|
# @macro report_by_day
|
155
|
-
has_report :earnings
|
155
|
+
has_report :earnings, Float
|
156
156
|
|
157
157
|
# @macro report_by_day
|
158
|
-
has_report :impressions
|
158
|
+
has_report :impressions, Integer
|
159
159
|
|
160
160
|
# @macro report_by_day
|
161
|
-
has_report :monetized_playbacks
|
161
|
+
has_report :monetized_playbacks, Integer
|
162
162
|
|
163
163
|
### STATISTICS ###
|
164
164
|
|
165
165
|
has_one :statistics_set
|
166
166
|
|
167
167
|
# @!attribute [r] view_count
|
168
|
-
#
|
168
|
+
# @return [Integer] the number of times the channel has been viewed.
|
169
169
|
delegate :view_count, to: :statistics_set
|
170
170
|
|
171
171
|
# @!attribute [r] comment_count
|
172
|
-
#
|
172
|
+
# @return [Integer] the number of comments for the channel.
|
173
173
|
delegate :comment_count, to: :statistics_set
|
174
174
|
|
175
175
|
# @!attribute [r] video_count
|
176
|
-
#
|
176
|
+
# @return [Integer] the number of videos uploaded to the channel.
|
177
177
|
delegate :video_count, to: :statistics_set
|
178
178
|
|
179
179
|
# @!attribute [r] subscriber_count
|
180
|
-
#
|
180
|
+
# @return [Integer] the number of subscriber the channel has.
|
181
181
|
delegate :subscriber_count, to: :statistics_set
|
182
182
|
|
183
183
|
# @return [Boolean] whether the number of subscribers is publicly visible.
|
@@ -189,13 +189,13 @@ module Yt
|
|
189
189
|
|
190
190
|
has_one :content_owner_detail
|
191
191
|
|
192
|
-
# The name of the content owner linked to the channel.
|
193
192
|
# @!attribute [r] content_owner
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
198
|
-
#
|
193
|
+
# The name of the content owner linked to the channel.
|
194
|
+
# @return [String] if the channel is partnered, its content owner’s name.
|
195
|
+
# @return [nil] if the channel is not partnered or if {Resource#auth auth}
|
196
|
+
# is a content owner without permissions to administer the channel.
|
197
|
+
# @raise [Yt::Errors::Forbidden] if {Resource#auth auth} does not
|
198
|
+
# return an authenticated content owner.
|
199
199
|
delegate :content_owner, to: :content_owner_detail
|
200
200
|
|
201
201
|
# Returns the time the channel was partnered to a content owner.
|
@@ -2,6 +2,7 @@ require 'yt/models/base'
|
|
2
2
|
|
3
3
|
module Yt
|
4
4
|
module Models
|
5
|
+
# @private
|
5
6
|
# Encapsulates information about the video content, including the length
|
6
7
|
# of the video and an indication of whether captions are available.
|
7
8
|
# @see https://developers.google.com/youtube/v3/docs/videos#resource
|