Class: Yt::Models::VideoGroup
- Inherits:
-
Base
- Object
- Base
- Yt::Models::VideoGroup
- Defined in:
- lib/yt/models/video_group.rb
Overview
Provides methods to interact with YouTube Analytics video-groups.
Instance Attribute Summary collapse
-
#group_items ⇒ Yt::Collections::GroupItems
readonly
The group’s items.
-
#item_count ⇒ Integer
readonly
The number of resources in the group.
-
#published_at ⇒ Time
readonly
The date and time when the group was created.
-
#title ⇒ String
readonly
The title of the group.
Instance Method Summary collapse
-
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
- #all_channel_ids ⇒ Object
- #all_video_ids ⇒ Object
-
#annotation_click_through_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_click_through_rate grouped by the given dimension.
-
#annotation_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the annotation_clicks grouped by the given dimension.
-
#annotation_close_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_close_rate grouped by the given dimension.
-
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
-
#average_view_percentage(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_view_percentage grouped by the given dimension.
-
#card_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_click_rate grouped by the given dimension.
-
#card_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_clicks grouped by the given dimension.
-
#card_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_impressions grouped by the given dimension.
-
#card_teaser_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_teaser_click_rate grouped by the given dimension.
-
#card_teaser_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_clicks grouped by the given dimension.
-
#card_teaser_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_impressions grouped by the given dimension.
- #channels ⇒ Object
-
#comments(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the comments grouped by the given dimension.
-
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
-
#estimated_minutes_watched(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
-
#estimated_revenue(options = {}) ⇒ Hash<Date, Float>, ...
Returns the estimated_revenue grouped by the given dimension.
-
#likes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the likes grouped by the given dimension.
-
#monetized_playbacks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the monetized_playbacks grouped by the given dimension.
-
#playback_based_cpm(options = {}) ⇒ Hash<Date, Float>, ...
Returns the playback_based_cpm grouped by the given dimension.
-
#reports(options = {}) ⇒ Hash<Symbol, Hash>
Returns the reports for the given metrics grouped by the given dimension.
-
#shares(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the shares grouped by the given dimension.
-
#subscribers_gained(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_gained grouped by the given dimension.
-
#subscribers_lost(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_lost grouped by the given dimension.
- #videos ⇒ Object
-
#videos_added_to_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_added_to_playlists grouped by the given dimension.
-
#videos_removed_from_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_removed_from_playlists grouped by the given dimension.
-
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
-
#views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the views grouped by the given dimension.
Instance Attribute Details
#group_items ⇒ Yt::Collections::GroupItems (readonly)
Returns the group’s items.
31 |
# File 'lib/yt/models/video_group.rb', line 31 has_many :group_items |
#item_count ⇒ Integer (readonly)
Returns the number of resources in the group.
21 |
# File 'lib/yt/models/video_group.rb', line 21 delegate :item_count, to: :group_info |
#published_at ⇒ Time (readonly)
Returns the date and time when the group was created.
25 |
# File 'lib/yt/models/video_group.rb', line 25 delegate :published_at, to: :group_info |
#title ⇒ String (readonly)
Returns the title of the group.
17 |
# File 'lib/yt/models/video_group.rb', line 17 delegate :title, to: :group_info |
Instance Method Details
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
111 |
# File 'lib/yt/models/video_group.rb', line 111 has_report :ad_impressions, Integer |
#all_channel_ids ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/yt/models/video_group.rb', line 163 def all_channel_ids resource_ids = group_items.map {|item| item.data['resource']['id']}.uniq case group_info.data['itemType'] when "youtube#video" resource_ids.flat_map do |video_id| Yt::Video.new(id: video_id, auth: @auth).channel_id end.uniq when "youtube#channel" resource_ids else [] end end |
#all_video_ids ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/yt/models/video_group.rb', line 141 def all_video_ids resource_ids = group_items.map{|item| item.data['resource']['id']}.uniq case group_info.data["itemType"] when "youtube#video" resource_ids when "youtube#channel" resource_ids.flat_map do |channel_id| Yt::Channel.new(id: channel_id, auth: @auth).videos.map(&:id) end else [] end end |
#annotation_click_through_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_click_through_rate grouped by the given dimension.
84 |
# File 'lib/yt/models/video_group.rb', line 84 has_report :annotation_click_through_rate, Float |
#annotation_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the annotation_clicks grouped by the given dimension.
81 |
# File 'lib/yt/models/video_group.rb', line 81 has_report :annotation_clicks, Integer |
#annotation_close_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_close_rate grouped by the given dimension.
87 |
# File 'lib/yt/models/video_group.rb', line 87 has_report :annotation_close_rate, Float |
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
75 |
# File 'lib/yt/models/video_group.rb', line 75 has_report :average_view_duration, Integer |
#average_view_percentage(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_view_percentage grouped by the given dimension.
78 |
# File 'lib/yt/models/video_group.rb', line 78 has_report :average_view_percentage, Float |
#card_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_click_rate grouped by the given dimension.
96 |
# File 'lib/yt/models/video_group.rb', line 96 has_report :card_click_rate, Float |
#card_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_clicks grouped by the given dimension.
93 |
# File 'lib/yt/models/video_group.rb', line 93 has_report :card_clicks, Integer |
#card_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_impressions grouped by the given dimension.
90 |
# File 'lib/yt/models/video_group.rb', line 90 has_report :card_impressions, Integer |
#card_teaser_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_teaser_click_rate grouped by the given dimension.
105 |
# File 'lib/yt/models/video_group.rb', line 105 has_report :card_teaser_click_rate, Float |
#card_teaser_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_clicks grouped by the given dimension.
102 |
# File 'lib/yt/models/video_group.rb', line 102 has_report :card_teaser_clicks, Integer |
#card_teaser_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_impressions grouped by the given dimension.
99 |
# File 'lib/yt/models/video_group.rb', line 99 has_report :card_teaser_impressions, Integer |
#channels ⇒ Object
177 178 179 180 181 182 183 |
# File 'lib/yt/models/video_group.rb', line 177 def channels all_channel_ids.each_slice(50).flat_map do |channel_ids| conditions = {id: channel_ids.join(',')} conditions[:part] = 'snippet' Collections::Channels.new(auth: @auth).where(conditions).map(&:itself) end end |
#comments(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the comments grouped by the given dimension.
47 |
# File 'lib/yt/models/video_group.rb', line 47 has_report :comments, Integer |
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
53 |
# File 'lib/yt/models/video_group.rb', line 53 has_report :dislikes, Integer |
#estimated_minutes_watched(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
41 |
# File 'lib/yt/models/video_group.rb', line 41 has_report :estimated_minutes_watched, Integer |
#estimated_revenue(options = {}) ⇒ Hash<Date, Float>, ...
Returns the estimated_revenue grouped by the given dimension.
108 |
# File 'lib/yt/models/video_group.rb', line 108 has_report :estimated_revenue, Float |
#likes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the likes grouped by the given dimension.
50 |
# File 'lib/yt/models/video_group.rb', line 50 has_report :likes, Integer |
#monetized_playbacks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the monetized_playbacks grouped by the given dimension.
114 |
# File 'lib/yt/models/video_group.rb', line 114 has_report :monetized_playbacks, Integer |
#playback_based_cpm(options = {}) ⇒ Hash<Date, Float>, ...
Returns the playback_based_cpm grouped by the given dimension.
117 |
# File 'lib/yt/models/video_group.rb', line 117 has_report :playback_based_cpm, Float |
#reports(options = {}) ⇒ Hash<Symbol, Hash>
Returns the reports for the given metrics grouped by the given dimension.
|
# File 'lib/yt/models/video_group.rb', line 35
|
#shares(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the shares grouped by the given dimension.
56 |
# File 'lib/yt/models/video_group.rb', line 56 has_report :shares, Integer |
#subscribers_gained(options = {}) ⇒ Hash<Date, Integer>, ...
This is not the total number of subscribers gained by the video’s channel, but the subscribers gained from the video’s page.
Returns the subscribers_gained grouped by the given dimension.
61 |
# File 'lib/yt/models/video_group.rb', line 61 has_report :subscribers_gained, Integer |
#subscribers_lost(options = {}) ⇒ Hash<Date, Integer>, ...
This is not the total number of subscribers lost by the video’s channel, but the subscribers lost from the video’s page.
Returns the subscribers_lost grouped by the given dimension.
66 |
# File 'lib/yt/models/video_group.rb', line 66 has_report :subscribers_lost, Integer |
#videos ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/yt/models/video_group.rb', line 155 def videos all_video_ids.each_slice(50).flat_map do |video_ids| conditions = {id: video_ids.join(',')} conditions[:part] = 'snippet,status,statistics,contentDetails' Collections::Videos.new(auth: @auth).where(conditions).map(&:itself) end end |
#videos_added_to_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_added_to_playlists grouped by the given dimension.
69 |
# File 'lib/yt/models/video_group.rb', line 69 has_report :videos_added_to_playlists, Integer |
#videos_removed_from_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_removed_from_playlists grouped by the given dimension.
72 |
# File 'lib/yt/models/video_group.rb', line 72 has_report :videos_removed_from_playlists, Integer |
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
44 |
# File 'lib/yt/models/video_group.rb', line 44 has_report :viewer_percentage, Float |
#views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the views grouped by the given dimension.
38 |
# File 'lib/yt/models/video_group.rb', line 38 has_report :views, Integer |