Class: Yt::Models::Playlist
- Defined in:
- lib/yt/models/playlist.rb
Overview
Provides methods to interact with YouTube playlists.
Constant Summary
Constants inherited from Resource
Resource::CHANNEL_PATTERNS, Resource::PLAYLIST_PATTERNS, Resource::VIDEO_PATTERNS
Instance Attribute Summary collapse
-
#channel_id ⇒ String
readonly
The ID of the channel that the playlist belongs to.
-
#channel_title ⇒ String
readonly
The title of the channel that the playlist belongs to.
-
#description ⇒ String
readonly
The playlist’s description.
-
#item_count ⇒ Integer
readonly
The number of items in the playlist.
-
#playlist_items ⇒ Yt::Collections::PlaylistItems
readonly
The playlist’s items.
-
#published_at ⇒ Time
readonly
The date and time that the playlist was created.
-
#tags ⇒ Array<String>
readonly
The list of tags attached to the playlist.
-
#title ⇒ String
readonly
The playlist’s title.
Attributes inherited from Resource
Instance Method Summary collapse
-
#add_video(video_id, options = {}) ⇒ Yt::PlaylistItem
Adds a video to the playlist.
-
#add_video!(video_id, options = {}) ⇒ Yt::PlaylistItem
Adds a video to the playlist.
-
#add_videos(video_ids = [], options = {}) ⇒ Array<Yt::PlaylistItem>
Adds multiple videos to the playlist.
-
#add_videos!(video_ids = [], options = {}) ⇒ Array<Yt::PlaylistItem>
Adds multiple videos to the playlist.
-
#average_time_in_playlist(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_time_in_playlist grouped by the given dimension.
-
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
-
#delete(options = {}) ⇒ Boolean
Deletes the playlist.
-
#delete_playlist_items(attributes = {}) ⇒ Array<Boolean>
Deletes the playlist’s items matching all the given attributes.
-
#estimated_minutes_watched(options = {}) ⇒ Hash<Yt::Video, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
-
#playlist_starts(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the playlist_starts grouped by the given dimension.
-
#reports(options = {}) ⇒ Hash<Symbol, Hash>
Returns the reports for the given metrics grouped by the given dimension.
-
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the playlist’s thumbnail.
-
#update(attributes = {}) ⇒ Boolean
Updates the attributes of a playlist.
-
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
-
#views(options = {}) ⇒ Hash<Yt::Video, Integer>, ...
Returns the views grouped by the given dimension.
-
#views_per_playlist_start(options = {}) ⇒ Hash<Date, Float>, ...
Returns the views_per_playlist_start grouped by the given dimension.
Methods inherited from Resource
#private?, #public?, #unlisted?
Instance Attribute Details
#channel_id ⇒ String (readonly)
Returns the ID of the channel that the playlist belongs to.
34 |
# File 'lib/yt/models/playlist.rb', line 34 delegate :channel_id, to: :snippet |
#channel_title ⇒ String (readonly)
Returns the title of the channel that the playlist belongs to.
38 |
# File 'lib/yt/models/playlist.rb', line 38 delegate :channel_title, to: :snippet |
#description ⇒ String (readonly)
Returns the playlist’s description.
17 |
# File 'lib/yt/models/playlist.rb', line 17 delegate :description, to: :snippet |
#item_count ⇒ Integer (readonly)
Returns the number of items in the playlist.
50 |
# File 'lib/yt/models/playlist.rb', line 50 delegate :item_count, to: :content_detail |
#playlist_items ⇒ Yt::Collections::PlaylistItems (readonly)
Returns the playlist’s items.
158 |
# File 'lib/yt/models/playlist.rb', line 158 has_many :playlist_items |
#published_at ⇒ Time (readonly)
Returns the date and time that the playlist was created.
30 |
# File 'lib/yt/models/playlist.rb', line 30 delegate :published_at, to: :snippet |
#tags ⇒ Array<String> (readonly)
Returns the list of tags attached to the playlist.
42 |
# File 'lib/yt/models/playlist.rb', line 42 delegate :tags, to: :snippet |
#title ⇒ String (readonly)
Returns the playlist’s title.
13 |
# File 'lib/yt/models/playlist.rb', line 13 delegate :title, to: :snippet |
Instance Method Details
#add_video(video_id, options = {}) ⇒ Yt::PlaylistItem
Adds a video to the playlist. Unlike #add_video!, does not raise an error if video can’t be added.
95 96 97 98 |
# File 'lib/yt/models/playlist.rb', line 95 def add_video(video_id, = {}) playlist_item_params = playlist_item_params(video_id, ) playlist_items.insert playlist_item_params, ignore_errors: true end |
#add_video!(video_id, options = {}) ⇒ Yt::PlaylistItem
Adds a video to the playlist. Unlike #add_video, raises an error if video can’t be added.
109 110 111 112 |
# File 'lib/yt/models/playlist.rb', line 109 def add_video!(video_id, = {}) playlist_item_params = playlist_item_params(video_id, ) playlist_items.insert playlist_item_params end |
#add_videos(video_ids = [], options = {}) ⇒ Array<Yt::PlaylistItem>
Adds multiple videos to the playlist. Unlike #add_videos!, does not raise an error if videos can’t be added.
122 123 124 |
# File 'lib/yt/models/playlist.rb', line 122 def add_videos(video_ids = [], = {}) video_ids.map{|video_id| add_video video_id, } end |
#add_videos!(video_ids = [], options = {}) ⇒ Array<Yt::PlaylistItem>
Adds multiple videos to the playlist. Unlike #add_videos, raises an error if videos can’t be added.
134 135 136 |
# File 'lib/yt/models/playlist.rb', line 134 def add_videos!(video_ids = [], = {}) video_ids.map{|video_id| add_video! video_id, } end |
#average_time_in_playlist(options = {}) ⇒ Hash<Date, Float>, ...
Returns the average_time_in_playlist grouped by the given dimension.
180 |
# File 'lib/yt/models/playlist.rb', line 180 has_report :average_time_in_playlist, Float |
#average_view_duration(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the average_view_duration grouped by the given dimension.
174 |
# File 'lib/yt/models/playlist.rb', line 174 has_report :average_view_duration, Integer |
#delete(options = {}) ⇒ Boolean
Deletes the playlist.
58 59 60 61 |
# File 'lib/yt/models/playlist.rb', line 58 def delete( = {}) do_delete {@id = nil} !exists? end |
#delete_playlist_items(attributes = {}) ⇒ Array<Boolean>
Deletes the playlist’s items matching all the given attributes.
150 151 152 |
# File 'lib/yt/models/playlist.rb', line 150 def delete_playlist_items(attributes = {}) playlist_items.delete_all attributes end |
#estimated_minutes_watched(options = {}) ⇒ Hash<Yt::Video, Integer>, ...
Returns the estimated_minutes_watched grouped by the given dimension.
168 |
# File 'lib/yt/models/playlist.rb', line 168 has_report :estimated_minutes_watched, Integer |
#playlist_starts(options = {}) ⇒ Hash<Date, Integer>, ...
Returns the playlist_starts grouped by the given dimension.
177 |
# File 'lib/yt/models/playlist.rb', line 177 has_report :playlist_starts, Integer |
#reports(options = {}) ⇒ Hash<Symbol, Hash>
Returns the reports for the given metrics grouped by the given dimension.
|
# File 'lib/yt/models/playlist.rb', line 162
|
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of the playlist’s thumbnail.
26 |
# File 'lib/yt/models/playlist.rb', line 26 delegate :thumbnail_url, to: :snippet |
#update(attributes = {}) ⇒ Boolean
Updates the attributes of a playlist.
83 84 85 |
# File 'lib/yt/models/playlist.rb', line 83 def update(attributes = {}) super end |
#viewer_percentage(options = {}) ⇒ Hash<Symbol, Float>, ...
Returns the viewer_percentage grouped by the given dimension.
171 |
# File 'lib/yt/models/playlist.rb', line 171 has_report :viewer_percentage, Float |
#views(options = {}) ⇒ Hash<Yt::Video, Integer>, ...
Returns the views grouped by the given dimension.
165 |
# File 'lib/yt/models/playlist.rb', line 165 has_report :views, Integer |
#views_per_playlist_start(options = {}) ⇒ Hash<Date, Float>, ...
Returns the views_per_playlist_start grouped by the given dimension.
183 |
# File 'lib/yt/models/playlist.rb', line 183 has_report :views_per_playlist_start, Float |