Class: Yt::PlaylistItem

Inherits:
Resource show all
Defined in:
lib/yt/playlist_item.rb

Overview

Provides methods to interact with YouTube playlist items.

Instance Attribute Summary collapse

Attributes inherited from Resource

#data

Instance Method Summary collapse

Methods inherited from Resource

#id, #initialize, #inspect, #select, where

Constructor Details

This class inherits a constructor from Yt::Resource

Instance Attribute Details

#channel_idString (readonly)

Returns the ID of the channel that the playlist belongs to.

Returns:

  • (String)

    the ID of the channel that the playlist belongs to.



23
# File 'lib/yt/playlist_item.rb', line 23

has_attribute :channel_id, in: :snippet

#channel_titleString (readonly)

Returns the title of the channel that the playlist belongs to.

Returns:

  • (String)

    the title of the channel that the playlist belongs to.



27
# File 'lib/yt/playlist_item.rb', line 27

has_attribute :channel_title, in: :snippet

#descriptionString (readonly)

Returns the item’s description.

Returns:

  • (String)

    the item’s description.



# File 'lib/yt/playlist_item.rb', line 9

#playlist_idString (readonly)

Returns the ID of the playlist that the item belongs to.

Returns:

  • (String)

    the ID of the playlist that the item belongs to.



31
# File 'lib/yt/playlist_item.rb', line 31

has_attribute :playlist_id, in: :snippet

#positionInteger (readonly)

Returns the order in which the item appears in the playlist. The value uses a zero-based index so the first item has a position of 0.

Returns:

  • (Integer)

    the order in which the item appears in the playlist. The value uses a zero-based index so the first item has a position of 0.



36
# File 'lib/yt/playlist_item.rb', line 36

has_attribute :position, in: :snippet, type: Integer

#privacy_statusString (readonly)

Returns the item’s privacy status. Valid values are: “private”, “public”, and “unlisted”.

Returns:

  • (String)

    the item’s privacy status. Valid values are: “private”, “public”, and “unlisted”.



45
# File 'lib/yt/playlist_item.rb', line 45

has_attribute :privacy_status, in: :status

#published_atTime (readonly)

Returns the date and time that the item was added to the playlist.

Returns:

  • (Time)

    the date and time that the item was added to the playlist.



15
# File 'lib/yt/playlist_item.rb', line 15

has_attribute :published_at, in: :snippet, type: Time

#thumbnailsHash<String, Hash> (readonly)

Returns the thumbnails associated with the item.

Returns:

  • (Hash<String, Hash>)

    the thumbnails associated with the item.



19
# File 'lib/yt/playlist_item.rb', line 19

has_attribute :thumbnails, in: :snippet

#titleString (readonly)

Returns the item’s title.

Returns:

  • (String)

    the item’s title.



7
# File 'lib/yt/playlist_item.rb', line 7

has_attribute :title, in: :snippet

#video_idString (readonly)

Returns the ID of the video that the item refers to.

Returns:

  • (String)

    the ID of the video that the item refers to.



40
# File 'lib/yt/playlist_item.rb', line 40

has_attribute :video_id, in: %i(snippet resource_id)

Instance Method Details

#thumbnail_url(size = :default) ⇒ String?

Returns the URL of the item’s thumbnail.

Parameters:

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

    The size of the item’s thumbnail.

Returns:

  • (String)

    if size is :default, the URL of a 120x90px image.

  • (String)

    if size is :medium, the URL of a 320x180px image.

  • (String)

    if size is :high, the URL of a 480x360px image.

  • (String)

    if size is :standard, the URL of a 640x480px image.

  • (String)

    if size is :maxres, the URL of a 1280x720px image.

  • (nil)

    if the size is none of the above.



55
56
57
# File 'lib/yt/playlist_item.rb', line 55

def thumbnail_url(size = :default)
  thumbnails.fetch(size.to_s, {})['url']
end