Class: Yt::Models::Channel
- Defined in:
- lib/yt/models/channel.rb
Overview
Provides methods to interact with YouTube channels.
Instance Attribute Summary collapse
-
#comment_count ⇒ Integer
readonly
The number of comments for the channel.
-
#content_owner ⇒ String?
readonly
The name of the content owner linked to the channel.
-
#description ⇒ String
readonly
The channel’s description.
-
#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.
-
#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
#comment_count ⇒ Integer (readonly)
Returns the number of comments for the channel.
202 |
# File 'lib/yt/models/channel.rb', line 202 delegate :comment_count, to: :statistics_set |
#content_owner ⇒ String? (readonly)
The name of the content owner linked to the channel.
228 |
# File 'lib/yt/models/channel.rb', line 228 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 |
#playlists ⇒ Yt::Collections::Playlists (readonly)
Returns the channel’s playlists.
95 |
# File 'lib/yt/models/channel.rb', line 95 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.
101 |
# File 'lib/yt/models/channel.rb', line 101 has_many :related_playlists |
#subscribed_channels ⇒ Yt::Collections::SubscribedChannels (readonly)
Returns the channels that this channel is subscribed to.
108 |
# File 'lib/yt/models/channel.rb', line 108 has_many :subscribed_channels |
#subscriber_count ⇒ Integer (readonly)
Returns the number of subscriber the channel has.
210 |
# File 'lib/yt/models/channel.rb', line 210 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.
206 |
# File 'lib/yt/models/channel.rb', line 206 delegate :video_count, to: :statistics_set |
#videos ⇒ Yt::Collections::Videos (readonly)
Returns the channel’s videos.
91 |
# File 'lib/yt/models/channel.rb', line 91 has_many :videos |
#view_count ⇒ Integer (readonly)
Returns the number of times the channel has been viewed.
198 |
# File 'lib/yt/models/channel.rb', line 198 delegate :view_count, to: :statistics_set |
Instance Method Details
#ad_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the ad_impressions grouped by the given dimension.
184 |
# File 'lib/yt/models/channel.rb', line 184 has_report :ad_impressions, Integer |
#annotation_click_through_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_click_through_rate grouped by the given dimension.
157 |
# File 'lib/yt/models/channel.rb', line 157 has_report :annotation_click_through_rate, Float |
#annotation_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the annotation_clicks grouped by the given dimension.
154 |
# File 'lib/yt/models/channel.rb', line 154 has_report :annotation_clicks, Integer |
#annotation_close_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the annotation_close_rate grouped by the given dimension.
160 |
# File 'lib/yt/models/channel.rb', line 160 has_report :annotation_close_rate, Float |
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
148 |
# File 'lib/yt/models/channel.rb', line 148 has_report :average_view_duration, Integer |
#average_view_percentage(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_view_percentage grouped by the given dimension.
151 |
# File 'lib/yt/models/channel.rb', line 151 has_report :average_view_percentage, Float |
#card_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_click_rate grouped by the given dimension.
169 |
# File 'lib/yt/models/channel.rb', line 169 has_report :card_click_rate, Float |
#card_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_clicks grouped by the given dimension.
166 |
# File 'lib/yt/models/channel.rb', line 166 has_report :card_clicks, Integer |
#card_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_impressions grouped by the given dimension.
163 |
# File 'lib/yt/models/channel.rb', line 163 has_report :card_impressions, Integer |
#card_teaser_click_rate(options = {}) ⇒ Hash<Date, Float>, ...
Returns the card_teaser_click_rate grouped by the given dimension.
178 |
# File 'lib/yt/models/channel.rb', line 178 has_report :card_teaser_click_rate, Float |
#card_teaser_clicks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_clicks grouped by the given dimension.
175 |
# File 'lib/yt/models/channel.rb', line 175 has_report :card_teaser_clicks, Integer |
#card_teaser_impressions(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the card_teaser_impressions grouped by the given dimension.
172 |
# File 'lib/yt/models/channel.rb', line 172 has_report :card_teaser_impressions, Integer |
#comments(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the comments grouped by the given dimension.
124 |
# File 'lib/yt/models/channel.rb', line 124 has_report :comments, Integer |
#delete_playlists(attributes = {}) ⇒ Array<Boolean>
Deletes the channel’s playlists matching all the given attributes.
257 258 259 |
# File 'lib/yt/models/channel.rb', line 257 def delete_playlists(attributes = {}) playlists.delete_all attributes end |
#dislikes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the dislikes grouped by the given dimension.
130 |
# File 'lib/yt/models/channel.rb', line 130 has_report :dislikes, Integer |
#estimated_minutes_watched(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
118 |
# File 'lib/yt/models/channel.rb', line 118 has_report :estimated_minutes_watched, Integer |
#estimated_revenue(options = {}) ⇒ Hash<Date, Float>, ...
Returns the estimated_revenue grouped by the given dimension.
181 |
# File 'lib/yt/models/channel.rb', line 181 has_report :estimated_revenue, Float |
#likes(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the likes grouped by the given dimension.
127 |
# File 'lib/yt/models/channel.rb', line 127 has_report :likes, Integer |
#linked_at ⇒ Time?
Returns the time the channel was partnered to a content owner.
237 238 239 |
# File 'lib/yt/models/channel.rb', line 237 def linked_at content_owner_detail.time_linked end |
#monetized_playbacks(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the monetized_playbacks grouped by the given dimension.
187 |
# File 'lib/yt/models/channel.rb', line 187 has_report :monetized_playbacks, Integer |
#playback_based_cpm(options = {}) ⇒ Hash<Date, Float>, ...
Returns the playback_based_cpm grouped by the given dimension.
190 |
# File 'lib/yt/models/channel.rb', line 190 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 112
|
#shares(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the shares grouped by the given dimension.
133 |
# File 'lib/yt/models/channel.rb', line 133 has_report :shares, Integer |
#subscribe ⇒ Object
Subscribes the authenticated account to the channel. Unlike #subscribe!, does not raise an error if already subscribed.
50 51 52 53 54 55 |
# File 'lib/yt/models/channel.rb', line 50 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.
62 63 64 65 66 67 |
# File 'lib/yt/models/channel.rb', line 62 def subscribe! subscriptions.insert.tap do |subscription| throttle_subscriptions @subscription = subscription end end |
#subscribed? ⇒ Boolean
Returns whether the account is subscribed to the channel.
39 40 41 42 43 44 |
# File 'lib/yt/models/channel.rb', line 39 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.
213 214 215 |
# File 'lib/yt/models/channel.rb', line 213 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.
136 |
# File 'lib/yt/models/channel.rb', line 136 has_report :subscribers_gained, Integer |
#subscribers_lost(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the subscribers_lost grouped by the given dimension.
139 |
# File 'lib/yt/models/channel.rb', line 139 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.
73 74 75 |
# File 'lib/yt/models/channel.rb', line 73 def unsubscribe unsubscribe! if subscribed? end |
#unsubscribe! ⇒ Object
Unsubscribes the authenticated account from the channel. Unlike #unsubscribe, raises an error if already unsubscribed.
83 84 85 |
# File 'lib/yt/models/channel.rb', line 83 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.
142 |
# File 'lib/yt/models/channel.rb', line 142 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.
145 |
# File 'lib/yt/models/channel.rb', line 145 has_report :videos_removed_from_playlists, Integer |
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
121 |
# File 'lib/yt/models/channel.rb', line 121 has_report :viewer_percentage, Float |
#views(options = {}) ⇒ Hash<Symbol, Integer>, ...
Returns the views grouped by the given dimension.
115 |
# File 'lib/yt/models/channel.rb', line 115 has_report :views, Integer |