class YoutubeParser::Channels::ChannelsSection

Public Instance Methods

for_each_channel() { |channel.info| ... } click to toggle source
# File lib/youtube_parser/channels/channels_section.rb, line 12
def for_each_channel
  channel_urls.map do |url|
    channel_url = "#{client.class::BASE_URL}#{url}"
    opts = { channel_url: channel_url, client: client }

    yield YoutubeParser::Channel.new(opts).info
  end
end
info() click to toggle source
# File lib/youtube_parser/channels/channels_section.rb, line 8
def info
  @info ||= for_each_channel { |c| c }
end

Private Instance Methods

channel_urls() click to toggle source
# File lib/youtube_parser/channels/channels_section.rb, line 23
def channel_urls
  channels.map { |c| c.dig(*keys.channels_section_urls) }.compact
end
channels() click to toggle source
# File lib/youtube_parser/channels/channels_section.rb, line 27
def channels
  tabs = json.dig(*keys.section_tabs) || []
  tabs.map { |t| t.dig(*keys.channels_section) }.compact.first || []
end
json() click to toggle source
# File lib/youtube_parser/channels/channels_section.rb, line 32
def json
  @json ||= client.get("#{options.channel_url}/channels")
end