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
-
#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.
-
#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.
-
#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
#content_owner ⇒ String? (readonly)
The name of the content owner linked to the channel.
243 |
# File 'lib/yt/models/channel.rb', line 243 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.
225 |
# File 'lib/yt/models/channel.rb', line 225 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 |
#video_count ⇒ Integer (readonly)
Returns the number of videos uploaded to the channel.
221 |
# File 'lib/yt/models/channel.rb', line 221 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.
217 |
# File 'lib/yt/models/channel.rb', line 217 delegate :view_count, to: :statistics_set |
Instance Method Details
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
203 |
# File 'lib/yt/models/channel.rb', line 203 has_report :ad_impressions, Integer |
#annotation_click_through_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_click_through_rate grouped by the given dimension.
176 |
# File 'lib/yt/models/channel.rb', line 176 has_report :annotation_click_through_rate, Float |
#annotation_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the annotation_clicks grouped by the given dimension.
173 |
# File 'lib/yt/models/channel.rb', line 173 has_report :annotation_clicks, Integer |
#annotation_close_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_close_rate grouped by the given dimension.
179 |
# File 'lib/yt/models/channel.rb', line 179 has_report :annotation_close_rate, Float |
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
167 |
# File 'lib/yt/models/channel.rb', line 167 has_report :average_view_duration, Integer |
#average_view_percentage(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_view_percentage grouped by the given dimension.
170 |
# File 'lib/yt/models/channel.rb', line 170 has_report :average_view_percentage, Float |
#card_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_click_rate grouped by the given dimension.
188 |
# File 'lib/yt/models/channel.rb', line 188 has_report :card_click_rate, Float |
#card_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_clicks grouped by the given dimension.
185 |
# File 'lib/yt/models/channel.rb', line 185 has_report :card_clicks, Integer |
#card_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_impressions grouped by the given dimension.
182 |
# File 'lib/yt/models/channel.rb', line 182 has_report :card_impressions, Integer |
#card_teaser_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_teaser_click_rate grouped by the given dimension.
197 |
# File 'lib/yt/models/channel.rb', line 197 has_report :card_teaser_click_rate, Float |
#card_teaser_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_clicks grouped by the given dimension.
194 |
# File 'lib/yt/models/channel.rb', line 194 has_report :card_teaser_clicks, Integer |
#card_teaser_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_impressions grouped by the given dimension.
191 |
# File 'lib/yt/models/channel.rb', line 191 has_report :card_teaser_impressions, Integer |
#comments(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the comments grouped by the given dimension.
143 |
# File 'lib/yt/models/channel.rb', line 143 has_report :comments, Integer |
#delete_playlists(attributes = {}) ⇒ Array<Boolean>
Deletes the channel’s playlists matching all the given attributes.
272 273 274 |
# File 'lib/yt/models/channel.rb', line 272 def delete_playlists(attributes = {}) playlists.delete_all attributes end |
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
149 |
# File 'lib/yt/models/channel.rb', line 149 has_report :dislikes, Integer |
#estimated_minutes_watched(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
137 |
# File 'lib/yt/models/channel.rb', line 137 has_report :estimated_minutes_watched, Integer |
#estimated_revenue(options = {}) ⇒ Hash<Date, Float>, ...
Returns the estimated_revenue grouped by the given dimension.
200 |
# File 'lib/yt/models/channel.rb', line 200 has_report :estimated_revenue, Float |
#likes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the likes grouped by the given dimension.
146 |
# File 'lib/yt/models/channel.rb', line 146 has_report :likes, Integer |
#linked_at ⇒ Time?
Returns the time the channel was partnered to a content owner.
252 253 254 |
# File 'lib/yt/models/channel.rb', line 252 def linked_at content_owner_detail.time_linked end |
#monetized_playbacks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the monetized_playbacks grouped by the given dimension.
206 |
# File 'lib/yt/models/channel.rb', line 206 has_report :monetized_playbacks, Integer |
#playback_based_cpm(options = {}) ⇒ Hash<Date, Float>, ...
Returns the playback_based_cpm grouped by the given dimension.
209 |
# File 'lib/yt/models/channel.rb', line 209 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 131
|
#shares(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the shares grouped by the given dimension.
152 |
# File 'lib/yt/models/channel.rb', line 152 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.
228 229 230 |
# File 'lib/yt/models/channel.rb', line 228 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.
155 |
# File 'lib/yt/models/channel.rb', line 155 has_report :subscribers_gained, Integer |
#subscribers_lost(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_lost grouped by the given dimension.
158 |
# File 'lib/yt/models/channel.rb', line 158 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.
161 |
# File 'lib/yt/models/channel.rb', line 161 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.
164 |
# File 'lib/yt/models/channel.rb', line 164 has_report :videos_removed_from_playlists, Integer |
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
140 |
# File 'lib/yt/models/channel.rb', line 140 has_report :viewer_percentage, Float |
#views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the views grouped by the given dimension.
134 |
# File 'lib/yt/models/channel.rb', line 134 has_report :views, Integer |