Class: Yt::Playlist
Overview
Provides methods to interact with YouTube playlists.
Instance Attribute Summary collapse
-
#channel_id ⇒ String
readonly
The ID of the channel that published the playlist.
-
#channel_title ⇒ String
readonly
The title of the channel that published the playlist.
-
#description ⇒ String
readonly
The playlist’s description.
-
#item_count ⇒ <Integer>
readonly
The number of videos in the playlist.
-
#privacy_status ⇒ String
readonly
The playlist’s privacy status.
-
#published_at ⇒ Time
readonly
The date and time that the playlist was created.
-
#thumbnails ⇒ Hash<String, Hash>
readonly
The thumbnails associated with the playlist.
-
#title ⇒ String
readonly
The playlist’s title.
Attributes inherited from Resource
Instance Method Summary collapse
-
#canonical_url ⇒ String
The canonical form of the playlist’s URL.
-
#items ⇒ Yt::Relation<Yt::PlaylistItem>
The items of the playlist.
-
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the playlist’s thumbnail.
-
#videos ⇒ Yt::Relation<Yt::Video>
The videos of the playlist.
Methods inherited from Resource
#id, #initialize, #inspect, #select, where
Constructor Details
This class inherits a constructor from Yt::Resource
Instance Attribute Details
#channel_id ⇒ String (readonly)
Returns the ID of the channel that published the playlist.
23 |
# File 'lib/yt/playlist.rb', line 23 has_attribute :channel_id, in: :snippet |
#channel_title ⇒ String (readonly)
Returns the title of the channel that published the playlist.
27 |
# File 'lib/yt/playlist.rb', line 27 has_attribute :channel_title, in: :snippet |
#description ⇒ String (readonly)
Returns the playlist’s description.
|
# File 'lib/yt/playlist.rb', line 9
|
#item_count ⇒ <Integer> (readonly)
Returns the number of videos in the playlist.
40 |
# File 'lib/yt/playlist.rb', line 40 has_attribute :item_count, in: :content_details, type: Integer |
#privacy_status ⇒ String (readonly)
Returns the playlist’s privacy status. Valid values are: “private”, “public”, and “unlisted”.
36 |
# File 'lib/yt/playlist.rb', line 36 has_attribute :privacy_status, in: :status |
#published_at ⇒ Time (readonly)
Returns the date and time that the playlist was created.
15 |
# File 'lib/yt/playlist.rb', line 15 has_attribute :published_at, in: :snippet, type: Time |
#thumbnails ⇒ Hash<String, Hash> (readonly)
Returns the thumbnails associated with the playlist.
19 |
# File 'lib/yt/playlist.rb', line 19 has_attribute :thumbnails, in: :snippet |
#title ⇒ String (readonly)
Returns the playlist’s title.
7 |
# File 'lib/yt/playlist.rb', line 7 has_attribute :title, in: :snippet |
Instance Method Details
#canonical_url ⇒ String
Returns the canonical form of the playlist’s URL.
55 56 57 |
# File 'lib/yt/playlist.rb', line 55 def canonical_url "https://www.youtube.com/playlist?list=#{id}" end |
#items ⇒ Yt::Relation<Yt::PlaylistItem>
Returns the items of the playlist.
60 61 62 63 64 |
# File 'lib/yt/playlist.rb', line 60 def items @items ||= Relation.new(PlaylistItem, playlist_id: id) do || get '/youtube/v3/playlistItems', playlist_items_params() end end |
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the playlist’s thumbnail.
50 51 52 |
# File 'lib/yt/playlist.rb', line 50 def thumbnail_url(size = :default) thumbnails.fetch(size.to_s, {})['url'] end |
#videos ⇒ Yt::Relation<Yt::Video>
Returns the videos of the playlist.
67 68 69 70 71 72 73 |
# File 'lib/yt/playlist.rb', line 67 def videos @videos ||= Relation.new(Video, playlist_id: id) do || params = playlist_items_params(.merge parts: [:content_details]) items = get '/youtube/v3/playlistItems', params videos_for items, 'contentDetails', end end |