class Yt::Playlist

Provides methods to interact with YouTube playlists. @see developers.google.com/youtube/v3/docs/playlists

Public Instance Methods

canonical_url() click to toggle source

@return [String] the canonical form of the playlist’s URL.

# File lib/yt/playlist.rb, line 55
def canonical_url
  "https://www.youtube.com/playlist?list=#{id}"
end
items() click to toggle source

@return [Yt::Relation<Yt::PlaylistItem>] the items of the playlist.

# File lib/yt/playlist.rb, line 60
def items
  @items ||= Relation.new(PlaylistItem, playlist_id: id) do |options|
    get '/youtube/v3/playlistItems', playlist_items_params(options)
  end
end
thumbnail_url(size = :default) click to toggle source

Returns the URL of the playlist’s thumbnail. @param [Symbol, String] size The size of the playlist’s thumbnail. @return [String] if size is :default, the URL of a 120x90px image. @return [String] if size is :medium, the URL of a 320x180px image. @return [String] if size is :high, the URL of a 480x360px image. @return [String] if size is :standard, the URL of a 640x480px image. @return [String] if size is :maxres, the URL of a 1280x720px image. @return [nil] if the size is none of the above.

# File lib/yt/playlist.rb, line 50
def thumbnail_url(size = :default)
  thumbnails.fetch(size.to_s, {})['url']
end
videos() click to toggle source

@return [Yt::Relation<Yt::Video>] the videos of the playlist.

# File lib/yt/playlist.rb, line 67
def videos
  @videos ||= Relation.new(Video, playlist_id: id) do |options|
    params = playlist_items_params(options.merge parts: [:content_details])
    items = get '/youtube/v3/playlistItems', params
    videos_for items, 'contentDetails', options
  end
end