module Onebox
module Engine
class GfycatOnebox
include Engine
include JSON
matches_regexp(/^https?:\/\/gfycat\.com\//)
always_https
def self.priority
# This engine should have priority over WhitelistedGenericOnebox.
1
end
def url
"https://gfycat.com/cajax/get/#{match[:name]}"
end
def to_html
<<-HTML
HTML
end
def placeholder_html
<<-HTML
#{data[:gfyName]}
HTML
end
private
def match
@match ||= @url.match(/^https?:\/\/gfycat\.com\/(?.+)/)
end
def data
{
name: raw['gfyItem']['gfyName'],
url: @url,
posterUrl: raw['gfyItem']['posterUrl'],
webmUrl: raw['gfyItem']['webmUrl'],
mp4Url: raw['gfyItem']['mp4Url'],
width: raw['gfyItem']['width'],
height: raw['gfyItem']['height']
}
end
end
end
end