class YoutubeChannel
Public Class Methods
new(params, options)
click to toggle source
Calls superclass method
Youtube::new
# File lib/youtube.rb, line 89 def initialize(params, options) super @target_content = ['contents', 'twoColumnBrowseResultsRenderer', 'tabs', 1, 'tabRenderer', 'content', 'sectionListRenderer', 'contents', 0, 'itemSectionRenderer', 'contents', 0, 'gridRenderer', 'items'].freeze end
Public Instance Methods
download()
click to toggle source
# File lib/youtube.rb, line 94 def download first_video(URI.open(@url).read) do |content| item = content['gridVideoRenderer'] @cover = item['thumbnail']['thumbnails'].last['url'] title = item['title']['runs'][0]['text'] serial = title.scan(/\d+/).first.to_i url = "https://www.youtube.com#{item['navigationEndpoint']['commandMetadata']['webCommandMetadata']['url']}" mp4_file = serial_file title, @label, serial, 'mp4' mp3_file = serial_file title, @label, serial, 'mp3' youtube_download url, mp4_file, mp3_file end end
dump()
click to toggle source
# File lib/youtube.rb, line 109 def dump tag = @url.scan(%r|/c/([^/]*)|).flatten.first html = Nokogiri(URI(@url).open.read) label = html.css('meta[property="og:title"]').attr('content').text return { tag => { 'desc' => label, 'url' => "#{@url.scan(%r|(.*?/c/[^/]*)|).flatten.first}/videos?view=0&sort=dd&flow=grid", 'label' => label } } end