Class: Yt::Models::Channel
- Defined in:
- lib/yt/models/channel.rb
Overview
Provides methods to interact with YouTube channels.
Constant Summary
Constants inherited from Resource
Resource::CHANNEL_PATTERNS, Resource::PLAYLIST_PATTERNS, Resource::VIDEO_PATTERNS
Instance Attribute Summary collapse
-
#banner_external_url ⇒ String
readonly
The channel’s banner image URL.
-
#channel_sections ⇒ Yt::Collections::ChannelSections
readonly
The channel’s channel sections.
-
#content_owner ⇒ String?
readonly
The name of the content owner linked to the channel.
-
#description ⇒ String
readonly
The channel’s description.
- #made_for_kids? ⇒ Boolean readonly
-
#playlists ⇒ Yt::Collections::Playlists
readonly
The channel’s playlists.
-
#published_at ⇒ Time
readonly
The date and time that the channel was created.
-
#related_playlists ⇒ Yt::Collections::Playlists
readonly
The playlists associated with the channel, such as the playlist of uploaded or liked videos.
- #self_declared_made_for_kids? ⇒ Boolean readonly
-
#subscribed_channels ⇒ Yt::Collections::SubscribedChannels
readonly
The channels that this channel is subscribed to.
-
#subscriber_count ⇒ Integer
readonly
The number of subscriber the channel has.
-
#title ⇒ String
readonly
The channel’s title.
-
#unsubscribed_trailer ⇒ String
readonly
The channel’s trailer video id.
-
#video_count ⇒ Integer
readonly
The number of videos uploaded to the channel.
-
#videos ⇒ Yt::Collections::Videos
readonly
The channel’s videos.
-
#view_count ⇒ Integer
readonly
The number of times the channel has been viewed.
Attributes inherited from Resource
Instance Method Summary collapse
-
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
-
#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.
-
#comments(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the comments grouped by the given dimension.
-
#delete_playlists(attributes = {}) ⇒ Array<Boolean>
Deletes the channel’s playlists matching all the given attributes.
-
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
-
#engaged_views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the engaged_views 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.
-
#linked_at ⇒ Time?
Returns the time the channel was partnered to a content owner.
-
#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.
-
#subscribe ⇒ Object
Subscribes the authenticated account to the channel.
-
#subscribe! ⇒ Object
Subscribes the authenticated account to the channel.
-
#subscribed? ⇒ Boolean
Whether the account is subscribed to the channel.
-
#subscriber_count_visible? ⇒ Boolean
Whether the number of subscribers is publicly visible.
-
#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.
-
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the channel’s thumbnail.
-
#unsubscribe ⇒ Object
Unsubscribes the authenticated account from the channel.
-
#unsubscribe! ⇒ Object
Unsubscribes the authenticated account from the channel.
-
#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.
Methods inherited from Resource
#private?, #public?, #unlisted?
Instance Attribute Details
#banner_external_url ⇒ String (readonly)
Returns the channel’s banner image URL.
249 |
# File 'lib/yt/models/channel.rb', line 249 delegate :banner_external_url, to: :branding_setting |
#channel_sections ⇒ Yt::Collections::ChannelSections (readonly)
Returns the channel’s channel sections.
131 |
# File 'lib/yt/models/channel.rb', line 131 has_many :channel_sections |
#content_owner ⇒ String? (readonly)
The name of the content owner linked to the channel.
262 |
# File 'lib/yt/models/channel.rb', line 262 delegate :content_owner, to: :content_owner_detail |
#description ⇒ String (readonly)
Returns the channel’s description.
17 |
# File 'lib/yt/models/channel.rb', line 17 delegate :description, to: :snippet |
#made_for_kids? ⇒ Boolean (readonly)
38 39 40 |
# File 'lib/yt/models/channel.rb', line 38 def made_for_kids? status.made_for_kids end |
#playlists ⇒ Yt::Collections::Playlists (readonly)
Returns the channel’s playlists.
114 |
# File 'lib/yt/models/channel.rb', line 114 has_many :playlists |
#published_at ⇒ Time (readonly)
Returns the date and time that the channel was created.
30 |
# File 'lib/yt/models/channel.rb', line 30 delegate :published_at, to: :snippet |
#related_playlists ⇒ Yt::Collections::Playlists (readonly)
Returns the playlists associated with the channel, such as the playlist of uploaded or liked videos.
120 |
# File 'lib/yt/models/channel.rb', line 120 has_many :related_playlists |
#self_declared_made_for_kids? ⇒ Boolean (readonly)
47 48 49 |
# File 'lib/yt/models/channel.rb', line 47 def self_declared_made_for_kids? status.self_declared_made_for_kids end |
#subscribed_channels ⇒ Yt::Collections::SubscribedChannels (readonly)
Returns the channels that this channel is subscribed to.
127 |
# File 'lib/yt/models/channel.rb', line 127 has_many :subscribed_channels |
#subscriber_count ⇒ Integer (readonly)
Returns the number of subscriber the channel has.
232 |
# File 'lib/yt/models/channel.rb', line 232 delegate :subscriber_count, to: :statistics_set |
#title ⇒ String (readonly)
Returns the channel’s title.
13 |
# File 'lib/yt/models/channel.rb', line 13 delegate :title, to: :snippet |
#unsubscribed_trailer ⇒ String (readonly)
Returns the channel’s trailer video id.
245 |
# File 'lib/yt/models/channel.rb', line 245 delegate :unsubscribed_trailer, to: :branding_setting |
#video_count ⇒ Integer (readonly)
Returns the number of videos uploaded to the channel.
228 |
# File 'lib/yt/models/channel.rb', line 228 delegate :video_count, to: :statistics_set |
#videos ⇒ Yt::Collections::Videos (readonly)
Returns the channel’s videos.
110 |
# File 'lib/yt/models/channel.rb', line 110 has_many :videos |
#view_count ⇒ Integer (readonly)
Returns the number of times the channel has been viewed.
224 |
# File 'lib/yt/models/channel.rb', line 224 delegate :view_count, to: :statistics_set |
Instance Method Details
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
210 |
# File 'lib/yt/models/channel.rb', line 210 has_report :ad_impressions, Integer |
#annotation_click_through_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_click_through_rate grouped by the given dimension.
183 |
# File 'lib/yt/models/channel.rb', line 183 has_report :annotation_click_through_rate, Float |
#annotation_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the annotation_clicks grouped by the given dimension.
180 |
# File 'lib/yt/models/channel.rb', line 180 has_report :annotation_clicks, Integer |
#annotation_close_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_close_rate grouped by the given dimension.
186 |
# File 'lib/yt/models/channel.rb', line 186 has_report :annotation_close_rate, Float |
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
174 |
# File 'lib/yt/models/channel.rb', line 174 has_report :average_view_duration, Integer |
#average_view_percentage(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_view_percentage grouped by the given dimension.
177 |
# File 'lib/yt/models/channel.rb', line 177 has_report :average_view_percentage, Float |
#card_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_click_rate grouped by the given dimension.
195 |
# File 'lib/yt/models/channel.rb', line 195 has_report :card_click_rate, Float |
#card_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_clicks grouped by the given dimension.
192 |
# File 'lib/yt/models/channel.rb', line 192 has_report :card_clicks, Integer |
#card_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_impressions grouped by the given dimension.
189 |
# File 'lib/yt/models/channel.rb', line 189 has_report :card_impressions, Integer |
#card_teaser_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_teaser_click_rate grouped by the given dimension.
204 |
# File 'lib/yt/models/channel.rb', line 204 has_report :card_teaser_click_rate, Float |
#card_teaser_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_clicks grouped by the given dimension.
201 |
# File 'lib/yt/models/channel.rb', line 201 has_report :card_teaser_clicks, Integer |
#card_teaser_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_impressions grouped by the given dimension.
198 |
# File 'lib/yt/models/channel.rb', line 198 has_report :card_teaser_impressions, Integer |
#comments(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the comments grouped by the given dimension.
150 |
# File 'lib/yt/models/channel.rb', line 150 has_report :comments, Integer |
#delete_playlists(attributes = {}) ⇒ Array<Boolean>
Deletes the channel’s playlists matching all the given attributes.
291 292 293 |
# File 'lib/yt/models/channel.rb', line 291 def delete_playlists(attributes = {}) playlists.delete_all attributes end |
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
156 |
# File 'lib/yt/models/channel.rb', line 156 has_report :dislikes, Integer |
#engaged_views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the engaged_views grouped by the given dimension.
141 |
# File 'lib/yt/models/channel.rb', line 141 has_report :engaged_views, Integer |
#estimated_minutes_watched(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
144 |
# File 'lib/yt/models/channel.rb', line 144 has_report :estimated_minutes_watched, Integer |
#estimated_revenue(options = {}) ⇒ Hash<Date, Float>, ...
Returns the estimated_revenue grouped by the given dimension.
207 |
# File 'lib/yt/models/channel.rb', line 207 has_report :estimated_revenue, Float |
#likes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the likes grouped by the given dimension.
153 |
# File 'lib/yt/models/channel.rb', line 153 has_report :likes, Integer |
#linked_at ⇒ Time?
Returns the time the channel was partnered to a content owner.
271 272 273 |
# File 'lib/yt/models/channel.rb', line 271 def linked_at content_owner_detail.time_linked end |
#monetized_playbacks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the monetized_playbacks grouped by the given dimension.
213 |
# File 'lib/yt/models/channel.rb', line 213 has_report :monetized_playbacks, Integer |
#playback_based_cpm(options = {}) ⇒ Hash<Date, Float>, ...
Returns the playback_based_cpm grouped by the given dimension.
216 |
# File 'lib/yt/models/channel.rb', line 216 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/channel.rb', line 135
|
#shares(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the shares grouped by the given dimension.
159 |
# File 'lib/yt/models/channel.rb', line 159 has_report :shares, Integer |
#subscribe ⇒ Object
Subscribes the authenticated account to the channel. Unlike #subscribe!, does not raise an error if already subscribed.
69 70 71 72 73 74 |
# File 'lib/yt/models/channel.rb', line 69 def subscribe subscriptions.insert(ignore_errors: true).tap do |subscription| throttle_subscriptions @subscription = subscription end end |
#subscribe! ⇒ Object
Subscribes the authenticated account to the channel. Unlike #subscribe, raises an error if already subscribed.
81 82 83 84 85 86 |
# File 'lib/yt/models/channel.rb', line 81 def subscribe! subscriptions.insert.tap do |subscription| throttle_subscriptions @subscription = subscription end end |
#subscribed? ⇒ Boolean
Returns whether the account is subscribed to the channel.
58 59 60 61 62 63 |
# File 'lib/yt/models/channel.rb', line 58 def subscribed? sleep [(@subscriptions_updated_at || Time.now) - Time.now, 0].max subscription.exists? rescue Errors::NoItems false end |
#subscriber_count_visible? ⇒ Boolean
Returns whether the number of subscribers is publicly visible.
235 236 237 |
# File 'lib/yt/models/channel.rb', line 235 def subscriber_count_visible? statistics_set.hidden_subscriber_count == false end |
#subscribers_gained(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_gained grouped by the given dimension.
162 |
# File 'lib/yt/models/channel.rb', line 162 has_report :subscribers_gained, Integer |
#subscribers_lost(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_lost grouped by the given dimension.
165 |
# File 'lib/yt/models/channel.rb', line 165 has_report :subscribers_lost, Integer |
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the channel’s thumbnail.
26 |
# File 'lib/yt/models/channel.rb', line 26 delegate :thumbnail_url, to: :snippet |
#unsubscribe ⇒ Object
Unsubscribes the authenticated account from the channel. Unlike #unsubscribe!, does not raise an error if already unsubscribed.
92 93 94 |
# File 'lib/yt/models/channel.rb', line 92 def unsubscribe unsubscribe! if subscribed? end |
#unsubscribe! ⇒ Object
Unsubscribes the authenticated account from the channel. Unlike #unsubscribe, raises an error if already unsubscribed.
102 103 104 |
# File 'lib/yt/models/channel.rb', line 102 def unsubscribe! subscription.delete.tap{ throttle_subscriptions } end |
#videos_added_to_playlists(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the videos_added_to_playlists grouped by the given dimension.
168 |
# File 'lib/yt/models/channel.rb', line 168 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.
171 |
# File 'lib/yt/models/channel.rb', line 171 has_report :videos_removed_from_playlists, Integer |
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
147 |
# File 'lib/yt/models/channel.rb', line 147 has_report :viewer_percentage, Float |
#views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the views grouped by the given dimension.
138 |
# File 'lib/yt/models/channel.rb', line 138 has_report :views, Integer |