Class: VideoInfo::Providers::Youtube
Instance Attribute Summary
#data, #iframe_attributes, #options, #url, #video_id
Class Method Summary
collapse
Instance Method Summary
collapse
#available?, #embed_code, #thumbnail
Constructor Details
#initialize(url, options = {}) ⇒ Youtube
Returns a new instance of Youtube.
8
9
10
11
12
13
14
15
16
|
# 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
|
Class Method Details
.usable?(url) ⇒ Boolean
18
19
20
21
|
# File 'lib/video_info/providers/youtube.rb', line 18
def self.usable?(url)
url =~ %r{(youtube\.com\/(?!playlist|embed\/videoseries).*)|
(youtu\.be)}x
end
|
Instance Method Details
#embed_url ⇒ Object
31
32
33
|
# File 'lib/video_info/providers/youtube.rb', line 31
def embed_url
"//www.youtube.com/embed/#{video_id}"
end
|
#provider ⇒ Object
23
24
25
|
# File 'lib/video_info/providers/youtube.rb', line 23
def provider
'YouTube'
end
|
#thumbnail_large ⇒ Object
43
44
45
|
# File 'lib/video_info/providers/youtube.rb', line 43
def thumbnail_large
"https://i.ytimg.com/vi/#{video_id}/hqdefault.jpg"
end
|
#thumbnail_large_2x ⇒ Object
47
48
49
|
# File 'lib/video_info/providers/youtube.rb', line 47
def thumbnail_large_2x
"https://i.ytimg.com/vi/#{video_id}/sddefault.jpg"
end
|
#thumbnail_maxres ⇒ Object
51
52
53
|
# File 'lib/video_info/providers/youtube.rb', line 51
def thumbnail_maxres
"https://i.ytimg.com/vi/#{video_id}/maxresdefault.jpg"
end
|
#thumbnail_medium ⇒ Object
39
40
41
|
# File 'lib/video_info/providers/youtube.rb', line 39
def thumbnail_medium
"https://i.ytimg.com/vi/#{video_id}/mqdefault.jpg"
end
|
#thumbnail_small ⇒ Object
35
36
37
|
# File 'lib/video_info/providers/youtube.rb', line 35
def thumbnail_small
"https://i.ytimg.com/vi/#{video_id}/default.jpg"
end
|