バグ #816 » 0001-Instagram.patch
core/plugin/photo_support/photo_support.rb | ||
---|---|---|
require 'totoridipjp'
|
||
module Plugin::PhotoSupport
|
||
INSTAGRAM_PATTERN = %r{^https?://(?:instagr\.am|instagram\.com)/p/([a-zA-Z0-9_\-]+)}
|
||
INSTAGRAM_PATTERN = %r{(?:instagr\.am|instagram\.com)/p/([a-zA-Z0-9_\-]+)/}
|
||
class << self
|
||
# Twitter cardsのURLを画像のURLに置き換える。
|
||
... | ... | |
# instagram
|
||
defimageopener('instagram', Plugin::PhotoSupport::INSTAGRAM_PATTERN) do |display_url|
|
||
m = display_url.match(Plugin::PhotoSupport::INSTAGRAM_PATTERN)
|
||
shortcode = m[1]
|
||
open("https://instagram.com/p/#{shortcode}/media/?size=l")
|
||
connection = HTTPClient.new
|
||
page = connection.get_content(display_url)
|
||
next nil if page.empty?
|
||
doc = Nokogiri::HTML(page)
|
||
result = doc.xpath("//meta[@property='og:image']/@content").first
|
||
open(result)
|
||
end
|
||
# d250g2
|