lib/film_snob/oembed_providers/youtube.rb
require "film_snob/oembed_provider"
class FilmSnob
class YouTube < OembedProvider
def self.valid_url_patterns
[
%r{
https?://(?:(?:www|m).)?youtube.com/watch\?
(?:feature=[\w\.]+&)?v=([\w\d\-_]+)
}x,
%r{https?://(?:(?:www|m).)?youtu.be/([\w\d\-_]+)},
%r{https?://(?:(?:www|m).)?youtube.com/v/([\w\d\-_]+)}
]
end
def self.oembed_endpoint
"https://www.youtube.com/oembed"
end
def clean_url
@clean_url ||= "https://www.youtube.com/watch?v=#{id}"
end
private
def friendly_options(options)
if (width = options.delete(:width) || options.delete("width"))
options[:maxwidth] = width
end
options
end
end
end