class VideoInfo::Providers::Youtube
Public Class Methods
new(url, options = {})
click to toggle source
Calls superclass method
VideoInfo::Provider::new
# File lib/video_info/providers/youtube.rb, line 8 def initialize(url, options = {}) if VideoInfo.provider_api_keys[:youtube].nil? extend YoutubeScraper else extend YoutubeAPI end super(url, options) end
usable?(url)
click to toggle source
# File lib/video_info/providers/youtube.rb, line 18 def self.usable?(url) url.match?(/(youtube\.com\/(?!playlist|embed\/videoseries).*)|(youtu\.be)/) end
Public Instance Methods
embed_url()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 30 def embed_url "//www.youtube.com/embed/#{video_id}" end
provider()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 22 def provider "YouTube" end
thumbnail_large()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 42 def thumbnail_large "https://i.ytimg.com/vi/#{video_id}/hqdefault.jpg" end
thumbnail_large_2x()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 46 def thumbnail_large_2x "https://i.ytimg.com/vi/#{video_id}/sddefault.jpg" end
thumbnail_maxres()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 50 def thumbnail_maxres "https://i.ytimg.com/vi/#{video_id}/maxresdefault.jpg" end
thumbnail_medium()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 38 def thumbnail_medium "https://i.ytimg.com/vi/#{video_id}/mqdefault.jpg" end
thumbnail_small()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 34 def thumbnail_small "https://i.ytimg.com/vi/#{video_id}/default.jpg" end
Private Instance Methods
_default_iframe_attributes()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 61 def _default_iframe_attributes {allowfullscreen: "allowfullscreen"} end
_default_url_attributes()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 65 def _default_url_attributes {} end
_url_regex()
click to toggle source
# File lib/video_info/providers/youtube.rb, line 56 def _url_regex %r{(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?|live|shorts)/| .*[?&]v=)|youtu\.be/)([^"&?/ ]{11})}x end
resize_thumb(url, size)
click to toggle source
# File lib/video_info/providers/youtube.rb, line 69 def resize_thumb(url, size) url.gsub(/(https:\/\/yt3.ggpht.com\/.*\/.*=s)([0-9]*)(.*)/, "\\1#{size}\\3") end