Class: Yt::Channel
Overview
Provides methods to interact with YouTube channels.
Instance Attribute Summary collapse
-
#banner_image_url ⇒ String
readonly
The URL for the banner image shown on the channel page on the YouTube website.
-
#comment_count ⇒ <Integer>
readonly
The number of comments for the channel.
-
#custom_url ⇒ <String, nil>
readonly
The path component of the channel’s custom URL.
-
#description ⇒ String
readonly
The channel’s description.
-
#featured_channels_title ⇒ Array<String>
readonly
The IDs of the channels linked in the featured channels module.
-
#hidden_subscriber_count ⇒ <Boolean>
readonly
Whether the channel’s subscriber count is publicly visible.
-
#is_linked ⇒ Boolean
readonly
Whether the channel data identifies a user that is already linked to either a YouTube username or a Google+ account.
-
#keywords ⇒ Array<String>
readonly
The keywords associated with the channel.
-
#long_uploads_status ⇒ String
readonly
Whether the channel is eligible to upload videos that are more than 15 minutes long.
-
#privacy_status ⇒ String
readonly
The privacy status of the channel.
-
#published_at ⇒ Time
readonly
The date and time that the channel was created.
-
#subscriber_count ⇒ <Integer>
readonly
The number of subscribers that the channel has.
-
#thumbnails ⇒ Hash<String, Hash>
readonly
The thumbnails associated with the video.
-
#title ⇒ String
readonly
The channel’s title.
-
#unsubscribed_trailer ⇒ <String, nil>
readonly
If specified, the ID of a public or unlisted video owned by the channel owner that should play in the featured video module in the channel page’s browse view for unsubscribed viewers.
-
#video_count ⇒ <Integer>
readonly
The number of videos uploaded to the channel.
-
#view_count ⇒ <Integer>
readonly
The number of times the channel has been viewed.
Attributes inherited from Resource
Instance Method Summary collapse
-
#canonical_url ⇒ String
The canonical form of the channel’s URL.
-
#playlists ⇒ Yt::Relation<Yt::Playlist>
The public playlists of the channel.
-
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of one of the channel’s thumbnail.
-
#vanity_url ⇒ <String] the full channel’s URL (custom or canonical).
<String] the full channel’s URL (custom or canonical).
-
#videos ⇒ Yt::Relation<Yt::Video>
of 500 videos.
Methods inherited from Resource
#id, #initialize, #inspect, #select, where
Constructor Details
This class inherits a constructor from Yt::Resource
Instance Attribute Details
#banner_image_url ⇒ String (readonly)
Returns the URL for the banner image shown on the channel page on the YouTube website. The image is 1060px by 175px.
70 |
# File 'lib/yt/channel.rb', line 70 has_attribute :banner_image_url, in: %i(branding_settings image) |
#comment_count ⇒ <Integer> (readonly)
Returns the number of comments for the channel.
52 |
# File 'lib/yt/channel.rb', line 52 has_attribute :comment_count, in: :statistics, type: Integer |
#custom_url ⇒ <String, nil> (readonly)
Returns the path component of the channel’s custom URL.
23 |
# File 'lib/yt/channel.rb', line 23 has_attribute :custom_url, in: :snippet |
#description ⇒ String (readonly)
Returns the channel’s description.
11 |
# File 'lib/yt/channel.rb', line 11 has_attribute :description, in: :snippet |
#featured_channels_title ⇒ Array<String> (readonly)
Returns the IDs of the channels linked in the featured channels module.
87 |
# File 'lib/yt/channel.rb', line 87 has_attribute :featured_channels_title, in: %i(branding_settings channel) |
#hidden_subscriber_count ⇒ <Boolean> (readonly)
Returns whether the channel’s subscriber count is publicly visible.
61 |
# File 'lib/yt/channel.rb', line 61 has_attribute :hidden_subscriber_count, in: :statistics |
#is_linked ⇒ Boolean (readonly)
Returns whether the channel data identifies a user that is already linked to either a YouTube username or a Google+ account.
37 |
# File 'lib/yt/channel.rb', line 37 has_attribute :is_linked, in: :status |
#keywords ⇒ Array<String> (readonly)
Returns the keywords associated with the channel.
74 75 76 |
# File 'lib/yt/channel.rb', line 74 has_attribute :keywords, in: %i(branding_settings channel) do |keywords| (keywords || '').split ' ' end |
#long_uploads_status ⇒ String (readonly)
“longUploadsUnspecified” is not documented by the YouTube API.
Returns whether the channel is eligible to upload videos that are more than 15 minutes long. Valid values are: “allowed”, “disallowed”, “eligible”, “longUploadsUnspecified”.
44 |
# File 'lib/yt/channel.rb', line 44 has_attribute :long_uploads_status, in: :status |
#privacy_status ⇒ String (readonly)
Returns the privacy status of the channel. Valid values are: “private”, “public”, “unlisted”.
32 |
# File 'lib/yt/channel.rb', line 32 has_attribute :privacy_status, in: :status |
#published_at ⇒ Time (readonly)
Returns the date and time that the channel was created.
15 |
# File 'lib/yt/channel.rb', line 15 has_attribute :published_at, in: :snippet, type: Time |
#subscriber_count ⇒ <Integer> (readonly)
Returns the number of subscribers that the channel has.
56 |
# File 'lib/yt/channel.rb', line 56 has_attribute :subscriber_count, in: :statistics, type: Integer |
#thumbnails ⇒ Hash<String, Hash> (readonly)
Returns the thumbnails associated with the video.
19 |
# File 'lib/yt/channel.rb', line 19 has_attribute :thumbnails, in: :snippet |
#title ⇒ String (readonly)
Returns the channel’s title.
7 |
# File 'lib/yt/channel.rb', line 7 has_attribute :title, in: :snippet |
#unsubscribed_trailer ⇒ <String, nil> (readonly)
Returns if specified, the ID of a public or unlisted video owned by the channel owner that should play in the featured video module in the channel page’s browse view for unsubscribed viewers.
82 |
# File 'lib/yt/channel.rb', line 82 has_attribute :unsubscribed_trailer, in: %i(branding_settings channel) |
#video_count ⇒ <Integer> (readonly)
Returns the number of videos uploaded to the channel.
65 |
# File 'lib/yt/channel.rb', line 65 has_attribute :video_count, in: :statistics, type: Integer |
#view_count ⇒ <Integer> (readonly)
Returns the number of times the channel has been viewed.
48 |
# File 'lib/yt/channel.rb', line 48 has_attribute :view_count, in: :statistics, type: Integer |
Instance Method Details
#canonical_url ⇒ String
Returns the canonical form of the channel’s URL.
95 96 97 |
# File 'lib/yt/channel.rb', line 95 def canonical_url "https://www.youtube.com/channel/#{id}" end |
#playlists ⇒ Yt::Relation<Yt::Playlist>
Returns the public playlists of the channel.
131 132 133 134 135 |
# File 'lib/yt/channel.rb', line 131 def playlists @playlists ||= Relation.new(Playlist, channel_id: id) do || fetch '/youtube/v3/playlists', channel_playlists_params() end end |
#thumbnail_url(size = :default) ⇒ String?
Returns the URL of one of the channel’s thumbnail.
115 116 117 |
# File 'lib/yt/channel.rb', line 115 def thumbnail_url(size = :default) thumbnails.fetch(size.to_s, {})['url'] end |
#vanity_url ⇒ <String] the full channel’s URL (custom or canonical).
Returns <String] the full channel’s URL (custom or canonical).
101 102 103 104 105 106 107 |
# File 'lib/yt/channel.rb', line 101 def vanity_url if custom_url "https://www.youtube.com/#{custom_url}" else canonical_url end end |
#videos ⇒ Yt::Relation<Yt::Video>
For unauthenticated channels, results are constrained to a maximum
of 500 videos.
123 124 125 126 127 128 |
# File 'lib/yt/channel.rb', line 123 def videos @videos ||= Relation.new(Video, channel_id: id, limit: 500) do || items = fetch '/youtube/v3/search', channel_videos_params() videos_for items, 'id', end end |