2013-10-09 11:40:10 -04:00
|
|
|
require_dependency 'oneboxer/oembed_onebox'
|
|
|
|
|
|
|
|
module Oneboxer
|
|
|
|
class YoutubeOnebox < OembedOnebox
|
|
|
|
matcher /^https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/.+$/
|
|
|
|
def oembed_endpoint
|
|
|
|
"http://www.youtube.com/oembed?url=#{BaseOnebox.uriencode(@url.sub('https://', 'http://'))}&format=json"
|
|
|
|
end
|
2013-10-09 14:43:59 -04:00
|
|
|
|
|
|
|
def onebox
|
|
|
|
# Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant
|
|
|
|
super.each { |entry| BaseOnebox.replace_agnostic entry }
|
|
|
|
end
|
2013-10-09 11:40:10 -04:00
|
|
|
end
|
|
|
|
end
|