Class: Yt::Models::Channel

Inherits:
Resource
  • Object
show all
Defined in:
lib/yt/models/channel.rb

Overview

Provides methods to interact with YouTube channels.

Instance Attribute Summary collapse

Attributes inherited from Resource

#id, #privacy_status

Instance Method Summary collapse

Methods inherited from Resource

#private?, #public?, #unlisted?

Instance Attribute Details

#comment_countInteger (readonly)

Returns the number of comments for the channel.

Returns:

  • (Integer)

    the number of comments for the channel.


202
# File 'lib/yt/models/channel.rb', line 202

delegate :comment_count, to: :statistics_set

#content_ownerString? (readonly)

The name of the content owner linked to the channel.

Returns:

  • (String)

    if the channel is partnered, its content owner’s name.

  • (nil)

    if the channel is not partnered or if auth is a content owner without permissions to administer the channel.

Raises:


228
# File 'lib/yt/models/channel.rb', line 228

delegate :content_owner, to: :content_owner_detail

#descriptionString (readonly)

Returns the channel’s description.

Returns:

  • (String)

    the channel’s description.


17
# File 'lib/yt/models/channel.rb', line 17

delegate :description, to: :snippet

#playlistsYt::Collections::Playlists (readonly)

Returns the channel’s playlists.

Returns:


95
# File 'lib/yt/models/channel.rb', line 95

has_many :playlists

#published_atTime (readonly)

Returns the date and time that the channel was created.

Returns:

  • (Time)

    the date and time that the channel was created.


30
# File 'lib/yt/models/channel.rb', line 30

delegate :published_at, to: :snippet

Returns the playlists associated with the channel, such as the playlist of uploaded or liked videos.

Returns:

See Also:


101
# File 'lib/yt/models/channel.rb', line 101

has_many :related_playlists

#subscribed_channelsYt::Collections::SubscribedChannels (readonly)

Returns the channels that this channel is subscribed to.

Returns:

Raises:

  • (Yt::Errors::Forbidden)

    if the owner of the channel has explicitly select the option to keep all subscriptions private.


108
# File 'lib/yt/models/channel.rb', line 108

has_many :subscribed_channels

#subscriber_countInteger (readonly)

Returns the number of subscriber the channel has.

Returns:

  • (Integer)

    the number of subscriber the channel has.


210
# File 'lib/yt/models/channel.rb', line 210

delegate :subscriber_count, to: :statistics_set

#titleString (readonly)

Returns the channel’s title.

Returns:

  • (String)

    the channel’s title.


13
# File 'lib/yt/models/channel.rb', line 13

delegate :title, to: :snippet

#video_countInteger (readonly)

Returns the number of videos uploaded to the channel.

Returns:

  • (Integer)

    the number of videos uploaded to the channel.


206
# File 'lib/yt/models/channel.rb', line 206

delegate :video_count, to: :statistics_set

#videosYt::Collections::Videos (readonly)

Returns the channel’s videos.

Returns:


91
# File 'lib/yt/models/channel.rb', line 91

has_many :videos

#view_countInteger (readonly)

Returns the number of times the channel has been viewed.

Returns:

  • (Integer)

    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.

Examples:

Get the ad_impressions for each day of last week:

resource.ad_impressions since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the ad_impressions for this and last month:

resource.ad_impressions since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the ad_impressions for this and last week:

resource.ad_impressions since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the ad_impressions for the whole last week:

resource.ad_impressions since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the ad_impressions for the whole last week in France only:

resource.ad_impressions since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the ad_impressions.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect ad_impressions by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the ad_impressions to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the ad_impressions for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the ad_impressions for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the ad_impressions for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the ad_impressions for the entire time-range (under the key :total).


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.

Examples:

Get the annotation_click_through_rate for each day of last week:

resource.annotation_click_through_rate since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the annotation_click_through_rate for this and last month:

resource.annotation_click_through_rate since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the annotation_click_through_rate for this and last week:

resource.annotation_click_through_rate since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the annotation_click_through_rate for the whole last week:

resource.annotation_click_through_rate since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the annotation_click_through_rate for the whole last week in Texas only:

resource.annotation_click_through_rate since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the annotation_click_through_rate.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect annotation_click_through_rate by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the annotation_click_through_rate to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Float>)

    if grouped by day, the annotation_click_through_rate for each day in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by month, the annotation_click_through_rate for each month in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by week, the annotation_click_through_rate for each week in the time-range.

  • (Hash<Symbol, Float>)

    if grouped by range, the annotation_click_through_rate for the entire time-range (under the key :total).


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.

Examples:

Get the annotation_clicks for each day of last week:

resource.annotation_clicks since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the annotation_clicks for this and last month:

resource.annotation_clicks since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the annotation_clicks for this and last week:

resource.annotation_clicks since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the annotation_clicks for the whole last week:

resource.annotation_clicks since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the annotation_clicks for the whole last week in Texas only:

resource.annotation_clicks since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the annotation_clicks.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect annotation_clicks by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the annotation_clicks to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the annotation_clicks for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the annotation_clicks for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the annotation_clicks for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the annotation_clicks for the entire time-range (under the key :total).


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.

Examples:

Get the annotation_close_rate for each day of last week:

resource.annotation_close_rate since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the annotation_close_rate for this and last month:

resource.annotation_close_rate since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the annotation_close_rate for this and last week:

resource.annotation_close_rate since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the annotation_close_rate for the whole last week:

resource.annotation_close_rate since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the annotation_close_rate for the whole last week in Texas only:

resource.annotation_close_rate since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the annotation_close_rate.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect annotation_close_rate by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the annotation_close_rate to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Float>)

    if grouped by day, the annotation_close_rate for each day in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by month, the annotation_close_rate for each month in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by week, the annotation_close_rate for each week in the time-range.

  • (Hash<Symbol, Float>)

    if grouped by range, the annotation_close_rate for the entire time-range (under the key :total).


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.

Examples:

Get the average_view_duration for each day of last week:

resource.average_view_duration since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the average_view_duration for this and last month:

resource.average_view_duration since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the average_view_duration for this and last week:

resource.average_view_duration since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the average_view_duration for the whole last week:

resource.average_view_duration since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the average_view_duration for the whole last week in Texas only:

resource.average_view_duration since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the average_view_duration.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect average_view_duration by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the average_view_duration to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the average_view_duration for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the average_view_duration for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the average_view_duration for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the average_view_duration for the entire time-range (under the key :total).


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.

Examples:

Get the average_view_percentage for each day of last week:

resource.average_view_percentage since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the average_view_percentage for this and last month:

resource.average_view_percentage since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the average_view_percentage for this and last week:

resource.average_view_percentage since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the average_view_percentage for the whole last week:

resource.average_view_percentage since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the average_view_percentage for the whole last week in Texas only:

resource.average_view_percentage since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the average_view_percentage.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect average_view_percentage by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the average_view_percentage to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Float>)

    if grouped by day, the average_view_percentage for each day in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by month, the average_view_percentage for each month in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by week, the average_view_percentage for each week in the time-range.

  • (Hash<Symbol, Float>)

    if grouped by range, the average_view_percentage for the entire time-range (under the key :total).


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.

Examples:

Get the card_click_rate for each day of last week:

resource.card_click_rate since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the card_click_rate for this and last month:

resource.card_click_rate since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the card_click_rate for this and last week:

resource.card_click_rate since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the card_click_rate for the whole last week:

resource.card_click_rate since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the card_click_rate for the whole last week in Texas only:

resource.card_click_rate since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the card_click_rate.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect card_click_rate by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the card_click_rate to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Float>)

    if grouped by day, the card_click_rate for each day in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by month, the card_click_rate for each month in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by week, the card_click_rate for each week in the time-range.

  • (Hash<Symbol, Float>)

    if grouped by range, the card_click_rate for the entire time-range (under the key :total).


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.

Examples:

Get the card_clicks for each day of last week:

resource.card_clicks since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the card_clicks for this and last month:

resource.card_clicks since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the card_clicks for this and last week:

resource.card_clicks since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the card_clicks for the whole last week:

resource.card_clicks since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the card_clicks for the whole last week in Texas only:

resource.card_clicks since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the card_clicks.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect card_clicks by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the card_clicks to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the card_clicks for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the card_clicks for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the card_clicks for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the card_clicks for the entire time-range (under the key :total).


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.

Examples:

Get the card_impressions for each day of last week:

resource.card_impressions since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the card_impressions for this and last month:

resource.card_impressions since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the card_impressions for this and last week:

resource.card_impressions since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the card_impressions for the whole last week:

resource.card_impressions since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the card_impressions for the whole last week in Texas only:

resource.card_impressions since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the card_impressions.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect card_impressions by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the card_impressions to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the card_impressions for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the card_impressions for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the card_impressions for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the card_impressions for the entire time-range (under the key :total).


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.

Examples:

Get the card_teaser_click_rate for each day of last week:

resource.card_teaser_click_rate since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the card_teaser_click_rate for this and last month:

resource.card_teaser_click_rate since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the card_teaser_click_rate for this and last week:

resource.card_teaser_click_rate since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the card_teaser_click_rate for the whole last week:

resource.card_teaser_click_rate since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the card_teaser_click_rate for the whole last week in Texas only:

resource.card_teaser_click_rate since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the card_teaser_click_rate.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect card_teaser_click_rate by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the card_teaser_click_rate to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Float>)

    if grouped by day, the card_teaser_click_rate for each day in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by month, the card_teaser_click_rate for each month in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by week, the card_teaser_click_rate for each week in the time-range.

  • (Hash<Symbol, Float>)

    if grouped by range, the card_teaser_click_rate for the entire time-range (under the key :total).


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.

Examples:

Get the card_teaser_clicks for each day of last week:

resource.card_teaser_clicks since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the card_teaser_clicks for this and last month:

resource.card_teaser_clicks since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the card_teaser_clicks for this and last week:

resource.card_teaser_clicks since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the card_teaser_clicks for the whole last week:

resource.card_teaser_clicks since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the card_teaser_clicks for the whole last week in Texas only:

resource.card_teaser_clicks since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the card_teaser_clicks.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect card_teaser_clicks by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the card_teaser_clicks to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the card_teaser_clicks for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the card_teaser_clicks for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the card_teaser_clicks for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the card_teaser_clicks for the entire time-range (under the key :total).


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.

Examples:

Get the card_teaser_impressions for each day of last week:

resource.card_teaser_impressions since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the card_teaser_impressions for this and last month:

resource.card_teaser_impressions since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the card_teaser_impressions for this and last week:

resource.card_teaser_impressions since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the card_teaser_impressions for the whole last week:

resource.card_teaser_impressions since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the card_teaser_impressions for the whole last week in Texas only:

resource.card_teaser_impressions since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the card_teaser_impressions.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect card_teaser_impressions by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the card_teaser_impressions to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the card_teaser_impressions for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the card_teaser_impressions for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the card_teaser_impressions for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the card_teaser_impressions for the entire time-range (under the key :total).


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.

Examples:

Get the comments for each day of last week:

resource.comments since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the comments for this and last month:

resource.comments since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the comments for this and last week:

resource.comments since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the comments for the whole last week:

resource.comments since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the comments for the whole last week in France only:

resource.comments since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the comments.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect comments by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the comments to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the comments for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the comments for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the comments for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the comments for the entire time-range (under the key :total).


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.

Parameters:

  • attributes (Hash) (defaults to: {})

    the attributes to match the playlists by.

Options Hash (attributes):

  • :title (<String, Regexp>)

    The playlist’s title. Pass a String for perfect match or a Regexp for advanced match.

  • :description (<String, Regexp>)

    The playlist’s description. Pass a String (perfect match) or a Regexp (advanced).

  • :tags (Array<String>)

    The playlist’s tags. All tags must match exactly.

  • :privacy_status (String)

    The playlist’s privacy status.

Returns:

  • (Array<Boolean>)

    whether each playlist matching the given attributes was deleted.

Raises:


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.

Examples:

Get the dislikes for each day of last week:

resource.dislikes since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the dislikes for this and last month:

resource.dislikes since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the dislikes for this and last week:

resource.dislikes since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the dislikes for the whole last week:

resource.dislikes since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the dislikes for the whole last week in France only:

resource.dislikes since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the dislikes.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect dislikes by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the dislikes to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the dislikes for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the dislikes for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the dislikes for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the dislikes for the entire time-range (under the key :total).


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.

Examples:

Get yesterday’s estimated_minutes_watched by embedded player location:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :embedded_player_location
# => {"fullscreen.net" => 92.0, "yahoo.com" => 14.0, …}

Get yesterday’s estimated_minutes_watched by video, eager-loading the status and statistics of each video:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :video, includes: [:status, :statistics]
# => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}

Get yesterday’s estimated_minutes_watched by playlist:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :playlist
# => {#<Yt::Playlist @id=…> => 33.0, #<Yt::Playlist @id=…> => 12.0, …}

Get yesterday’s estimated_minutes_watched grouped by playback location:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :playback_location
# => {embedded: 53.0, watch: 467.0, …}

Get yesterday’s estimated_minutes_watched by related video, eager-loading the snippet of each video

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :related_video, includes: [:snippet]
# => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}

Get yesterday’s estimated_minutes_watched by search term:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :search_term
# => {"fullscreen" => 33.0, "good music" => 12.0, …}

Get yesterday’s estimated_minutes_watched by URL that referred to the resource:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :referrer
# => {"Google Search" => 33.0, "ytimg.com" => 12.0, …}

Get yesterday’s estimated_minutes_watched by device type:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :device_type
# => {mobile: 133.0, tv: 412.0, …}

Get yesterday’s estimated_minutes_watched by traffic source:

resource.estimated_minutes_watched since: 1.day.ago, until: 1.day.ago, by: :traffic_source
# => {advertising: 543.0, playlist: 92.0, …}

Get the estimated_minutes_watched for each day of last week:

resource.estimated_minutes_watched since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the estimated_minutes_watched for this and last month:

resource.estimated_minutes_watched since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the estimated_minutes_watched for this and last week:

resource.estimated_minutes_watched since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the estimated_minutes_watched for the whole last week:

resource.estimated_minutes_watched since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the estimated_minutes_watched for the whole last week in Texas only:

resource.estimated_minutes_watched since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the estimated_minutes_watched.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect estimated_minutes_watched by. Accepted values are: :day, :week, :month, :range, :traffic_source, :search_term, :playback_location, :video, :related_video, :playlist, :embedded_player_location.

  • :includes (Array<Symbol>) — default: [:id]

    if grouped by video, related video, or playlist, the parts of each video or playlist to eager-load. Accepted values are: :id, :snippet, :status, :statistics, :content_details.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the estimated_minutes_watched to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Symbol, Integer>)

    if grouped by embedded player location, the estimated_minutes_watched for each embedded player location.

  • (Hash<Yt::Video, Integer>)

    if grouped by video, the estimated_minutes_watched for each video.

  • (Hash<Yt::Playlist, Integer>)

    if grouped by playlist, the estimated_minutes_watched for each playlist.

  • (Hash<Symbol, Integer>)

    if grouped by playback location, the estimated_minutes_watched for each traffic playback location.

  • (Hash<Yt::Video, Integer>)

    if grouped by related video, the estimated_minutes_watched for each related video.

  • (Hash<Symbol, Integer>)

    if grouped by device type, the estimated_minutes_watched for each device type.

  • (Hash<String, Integer>)

    if grouped by search term, the estimated_minutes_watched for each search term that led viewers to the content.

  • (Hash<String, Integer>)

    if grouped by search term, the estimated_minutes_watched for each search term that led viewers to the content.

  • (Hash<Symbol, Integer>)

    if grouped by traffic source, the estimated_minutes_watched for each traffic source.

  • (Hash<Date, Integer>)

    if grouped by day, the estimated_minutes_watched for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the estimated_minutes_watched for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the estimated_minutes_watched for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the estimated_minutes_watched for the entire time-range (under the key :total).


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.

Examples:

Get the estimated_revenue for each day of last week:

resource.estimated_revenue since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the estimated_revenue for this and last month:

resource.estimated_revenue since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the estimated_revenue for this and last week:

resource.estimated_revenue since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the estimated_revenue for the whole last week:

resource.estimated_revenue since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the estimated_revenue for the whole last week in France only:

resource.estimated_revenue since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the estimated_revenue.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect estimated_revenue by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the estimated_revenue to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Float>)

    if grouped by day, the estimated_revenue for each day in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by month, the estimated_revenue for each month in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by week, the estimated_revenue for each week in the time-range.

  • (Hash<Symbol, Float>)

    if grouped by range, the estimated_revenue for the entire time-range (under the key :total).


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.

Examples:

Get the likes for each day of last week:

resource.likes since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the likes for this and last month:

resource.likes since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the likes for this and last week:

resource.likes since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the likes for the whole last week:

resource.likes since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the likes for the whole last week in France only:

resource.likes since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the likes.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect likes by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the likes to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the likes for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the likes for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the likes for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the likes for the entire time-range (under the key :total).


127
# File 'lib/yt/models/channel.rb', line 127

has_report :likes, Integer

#linked_atTime?

Returns the time the channel was partnered to a content owner.

Returns:

  • (Time)

    if the channel is partnered, the time when it was linked to its content owner.

  • (nil)

    if the channel is not partnered or if auth is a content owner without permissions to administer the channel.

Raises:


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.

Examples:

Get the monetized_playbacks for each day of last week:

resource.monetized_playbacks since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the monetized_playbacks for this and last month:

resource.monetized_playbacks since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the monetized_playbacks for this and last week:

resource.monetized_playbacks since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the monetized_playbacks for the whole last week:

resource.monetized_playbacks since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the monetized_playbacks for the whole last week in France only:

resource.monetized_playbacks since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the monetized_playbacks.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect monetized_playbacks by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the monetized_playbacks to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the monetized_playbacks for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the monetized_playbacks for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the monetized_playbacks for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the monetized_playbacks for the entire time-range (under the key :total).


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.

Examples:

Get the playback_based_cpm for each day of last week:

resource.playback_based_cpm since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the playback_based_cpm for this and last month:

resource.playback_based_cpm since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the playback_based_cpm for this and last week:

resource.playback_based_cpm since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the playback_based_cpm for the whole last week:

resource.playback_based_cpm since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the playback_based_cpm for the whole last week in France only:

resource.playback_based_cpm since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the playback_based_cpm.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect playback_based_cpm by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the playback_based_cpm to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Float>)

    if grouped by day, the playback_based_cpm for each day in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by month, the playback_based_cpm for each month in the time-range.

  • (Hash<Range<Date, Date>, Float>)

    if grouped by week, the playback_based_cpm for each week in the time-range.

  • (Hash<Symbol, Float>)

    if grouped by range, the playback_based_cpm for the entire time-range (under the key :total).


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.

Examples:

Get the views and estimated minutes watched by day for last week:

resource.reports only: [:views, :estimated_minutes_watched] since: 1.week.ago, by: :day
# => {views: {Wed, 8 May 2014 => 12, Thu, 9 May 2014 => 34, …}, estimated_minutes_watched: {Wed, 8 May 2014 => 9, Thu, 9 May 2014 => 6, …}}

Parameters:

  • options (Hash) (defaults to: {})

    the metrics, time-range and dimensions for the reports.

Options Hash (options):

  • :only (Array<Symbol>)

    The metrics to generate reports for.

  • :by (Symbol) — default: :day

    The dimension to collect metrics by. Accepted values are: :day, :week, :month.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

Returns:

  • (Hash<Symbol, Hash>)

    the reports for each metric specified.


# File 'lib/yt/models/channel.rb', line 112

#shares(options = {}) ⇒ Hash<Date, Integer>, ...

Returns the shares grouped by the given dimension.

Examples:

Get the shares for each day of last week:

resource.shares since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the shares for this and last month:

resource.shares since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the shares for this and last week:

resource.shares since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the shares for the whole last week:

resource.shares since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the shares for the whole last week in France only:

resource.shares since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the shares.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect shares by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the shares to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the shares for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the shares for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the shares for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the shares for the entire time-range (under the key :total).


133
# File 'lib/yt/models/channel.rb', line 133

has_report :shares, Integer

#subscribeObject

Subscribes the authenticated account to the channel. Unlike #subscribe!, does not raise an error if already subscribed.

Raises:


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.

Raises:


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.

Returns:

  • (Boolean)

    whether the account is subscribed to the channel.

Raises:


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.

Returns:

  • (Boolean)

    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.

Examples:

Get the subscribers_gained for each day of last week:

resource.subscribers_gained since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the subscribers_gained for this and last month:

resource.subscribers_gained since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the subscribers_gained for this and last week:

resource.subscribers_gained since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the subscribers_gained for the whole last week:

resource.subscribers_gained since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the subscribers_gained for the whole last week in France only:

resource.subscribers_gained since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the subscribers_gained.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect subscribers_gained by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the subscribers_gained to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the subscribers_gained for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the subscribers_gained for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the subscribers_gained for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the subscribers_gained for the entire time-range (under the key :total).


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.

Examples:

Get the subscribers_lost for each day of last week:

resource.subscribers_lost since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the subscribers_lost for this and last month:

resource.subscribers_lost since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the subscribers_lost for this and last week:

resource.subscribers_lost since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the subscribers_lost for the whole last week:

resource.subscribers_lost since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the subscribers_lost for the whole last week in France only:

resource.subscribers_lost since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the subscribers_lost.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect subscribers_lost by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the subscribers_lost to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the subscribers_lost for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the subscribers_lost for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the subscribers_lost for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the subscribers_lost for the entire time-range (under the key :total).


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.

Parameters:

  • size (Symbol, String) (defaults to: :default)

    The size of the channel’s thumbnail.

Returns:

  • (String)

    if size is default, the URL of a 88x88px image.

  • (String)

    if size is medium, the URL of a 240x240px image.

  • (String)

    if size is high, the URL of a 800x800px image.

  • (nil)

    if the size is not default, medium or high.


26
# File 'lib/yt/models/channel.rb', line 26

delegate :thumbnail_url, to: :snippet

#unsubscribeObject

Unsubscribes the authenticated account from the channel. Unlike #unsubscribe!, does not raise an error if already unsubscribed.

Raises:


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.

Raises:


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.

Examples:

Get the videos_added_to_playlists for each day of last week:

resource.videos_added_to_playlists since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the videos_added_to_playlists for this and last month:

resource.videos_added_to_playlists since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the videos_added_to_playlists for this and last week:

resource.videos_added_to_playlists since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the videos_added_to_playlists for the whole last week:

resource.videos_added_to_playlists since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the videos_added_to_playlists for the whole last week in France only:

resource.videos_added_to_playlists since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the videos_added_to_playlists.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect videos_added_to_playlists by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the videos_added_to_playlists to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the videos_added_to_playlists for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the videos_added_to_playlists for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the videos_added_to_playlists for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the videos_added_to_playlists for the entire time-range (under the key :total).


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.

Examples:

Get the videos_removed_from_playlists for each day of last week:

resource.videos_removed_from_playlists since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the videos_removed_from_playlists for this and last month:

resource.videos_removed_from_playlists since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the videos_removed_from_playlists for this and last week:

resource.videos_removed_from_playlists since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the videos_removed_from_playlists for the whole last week:

resource.videos_removed_from_playlists since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the videos_removed_from_playlists for the whole last week in France only:

resource.videos_removed_from_playlists since: 2.weeks.ago, until: 1.week.ago, by: :range, in: 'FR'
# => {total: 44.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the videos_removed_from_playlists.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect videos_removed_from_playlists by. Accepted values are: :day, :week, :month, :range.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The country to limit the videos_removed_from_playlists to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash with the code in the :country key, such as {country: “US”}.

Returns:

  • (Hash<Date, Integer>)

    if grouped by day, the videos_removed_from_playlists for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the videos_removed_from_playlists for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the videos_removed_from_playlists for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the videos_removed_from_playlists for the entire time-range (under the key :total).


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.

Examples:

Get yesterday’s viewer percentage by gender:

resource.viewer_percentage since: 1.day.ago, until: 1.day.ago, by: :gender
# => {female: 53.0, male: 47.0}

Get yesterday’s viewer_percentage grouped by age group:

resource.viewer_percentage since: 1.day.ago, until: 1.day.ago, by: :age_group
# => {"18-24" => 4.54, "35-24" => 12.31, "45-34" => 8.92, …}

Get yesterday’s viewer_percentage by gender and age group:

resource.viewer_percentage since: 1.day.ago, until: 1.day.ago
# => {female: {"18-24" => 12.12, "25-34" => 16.16, …}, male:…}

Get yesterday’s viewer_percentage by gender and age group in France only:

resource.viewer_percentage since: 1.day.ago, until: 1.day.ago, in: 'FR'
# => {female: {"18-24" => 16.12, "25-34" => 13.16, …}, male:…}

Get the viewer_percentage for the whole last week in Texas only:

resource.viewer_percentage since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the viewer_percentage.

Options Hash (options):

  • :by (Symbol) — default: :gender_age_group

    The dimension to show viewer percentage by. Accepted values are: :gender, :age_group, :gender_age_group.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the viewer_percentage to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Symbol, Float>)

    if grouped by gender, the viewer percentage by gender.

  • (Hash<String, Float>)

    if grouped by age group, the viewer percentage by age group.

  • (Hash<Symbol, [Hash<String, Float>]>)

    if grouped by gender and age group, the viewer percentage by gender/age group.


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.

Examples:

Get yesterday’s views by embedded player location:

resource.views since: 1.day.ago, until: 1.day.ago, by: :embedded_player_location
# => {"fullscreen.net" => 92.0, "yahoo.com" => 14.0, …}

Get yesterday’s views by video, eager-loading the status and statistics of each video:

resource.views since: 1.day.ago, until: 1.day.ago, by: :video, includes: [:status, :statistics]
# => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}

Get yesterday’s views by playlist:

resource.views since: 1.day.ago, until: 1.day.ago, by: :playlist
# => {#<Yt::Playlist @id=…> => 33.0, #<Yt::Playlist @id=…> => 12.0, …}

Get yesterday’s views grouped by playback location:

resource.views since: 1.day.ago, until: 1.day.ago, by: :playback_location
# => {embedded: 53.0, watch: 467.0, …}

Get yesterday’s views by related video, eager-loading the snippet of each video

resource.views since: 1.day.ago, until: 1.day.ago, by: :related_video, includes: [:snippet]
# => {#<Yt::Video @id=…> => 33.0, #<Yt::Video @id=…> => 12.0, …}

Get yesterday’s views by search term:

resource.views since: 1.day.ago, until: 1.day.ago, by: :search_term
# => {"fullscreen" => 33.0, "good music" => 12.0, …}

Get yesterday’s views by URL that referred to the resource:

resource.views since: 1.day.ago, until: 1.day.ago, by: :referrer
# => {"Google Search" => 33.0, "ytimg.com" => 12.0, …}

Get yesterday’s views by device type:

resource.views since: 1.day.ago, until: 1.day.ago, by: :device_type
# => {mobile: 133.0, tv: 412.0, …}

Get yesterday’s views by traffic source:

resource.views since: 1.day.ago, until: 1.day.ago, by: :traffic_source
# => {advertising: 543.0, playlist: 92.0, …}

Get the views for each day of last week:

resource.views since: 2.weeks.ago, until: 1.week.ago, by: :day
# => {Wed, 8 May 2014 => 12.0, Thu, 9 May 2014 => 34.0, …}

Get the views for this and last month:

resource.views since: 1.month.ago, by: :month
# => {Wed, 01 Apr 2014..Thu, 30 Apr 2014 => 12.0, Fri, 01 May 2014..Sun, 31 May 2014 => 34.0, …}

Get the views for this and last week:

resource.views since: 1.week.ago, by: :week
# => {Wed, 01 Apr 2014..Tue, 07 Apr 2014 => 20.0, Wed, 08 Apr 2014..Tue, 14 Apr 2014 => 13.0, …}

Get the views for the whole last week:

resource.views since: 2.weeks.ago, until: 1.week.ago, by: :range
# => {total: 564.0}

Get the views for the whole last week in Texas only:

resource.views since: 2.weeks.ago, until: 1.week.ago, by: :range, in: {state: 'TX'}
# => {total: 19.0}

Parameters:

  • options (Hash) (defaults to: {})

    the time-range and dimensions for the views.

Options Hash (options):

  • :by (Symbol) — default: :day

    The dimension to collect views by. Accepted values are: :day, :week, :month, :range, :traffic_source, :search_term, :playback_location, :video, :related_video, :playlist, :embedded_player_location.

  • :includes (Array<Symbol>) — default: [:id]

    if grouped by video, related video, or playlist, the parts of each video or playlist to eager-load. Accepted values are: :id, :snippet, :status, :statistics, :content_details.

  • :since (#to_date)

    The first day of the time-range. Also aliased as :from.

  • :until (#to_date)

    The last day of the time-range. Also aliased as :to.

  • :in (<String, Hash>)

    The location to limit the views to. Can either be the two-letter ISO-3166-1 code of a country, such as “US”, or a Hash that either contains the :country key, such as {country: “US”} or the :state key, such as {state: “TX”}. Note that YouTube API only provides data for US states.

Returns:

  • (Hash<Symbol, Integer>)

    if grouped by embedded player location, the views for each embedded player location.

  • (Hash<Yt::Video, Integer>)

    if grouped by video, the views for each video.

  • (Hash<Yt::Playlist, Integer>)

    if grouped by playlist, the views for each playlist.

  • (Hash<Symbol, Integer>)

    if grouped by playback location, the views for each traffic playback location.

  • (Hash<Yt::Video, Integer>)

    if grouped by related video, the views for each related video.

  • (Hash<Symbol, Integer>)

    if grouped by device type, the views for each device type.

  • (Hash<String, Integer>)

    if grouped by search term, the views for each search term that led viewers to the content.

  • (Hash<String, Integer>)

    if grouped by search term, the views for each search term that led viewers to the content.

  • (Hash<Symbol, Integer>)

    if grouped by traffic source, the views for each traffic source.

  • (Hash<Date, Integer>)

    if grouped by day, the views for each day in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by month, the views for each month in the time-range.

  • (Hash<Range<Date, Date>, Integer>)

    if grouped by week, the views for each week in the time-range.

  • (Hash<Symbol, Integer>)

    if grouped by range, the views for the entire time-range (under the key :total).


115
# File 'lib/yt/models/channel.rb', line 115

has_report :views, Integer