提案 #1301 » 0001-photo_support-Amazon-URL.patch
core/plugin/photo_support/photo_support.rb | ||
---|---|---|
img = Plugin::PhotoSupport.d250g2(display_url)
|
||
open(img) if img
|
||
end
|
||
# Amazon
|
||
amazon_json_regex = %r!'colorImages': { 'initial': (\[.*MAIN.*\])!.freeze
|
||
defimageopener('Amazon', %r<\Ahttps?://www\.amazon\.(?:co\.jp|com)/(?:.*/)?(?:dp/|gp/product/)[0-9A-Za-z_]+>) do |url|
|
||
html = HTTPClient.new.get_content(url, [], [['User-Agent', 'mikutter']])
|
||
m = amazon_json_regex.match(html)
|
||
next nil unless m
|
||
arr = JSON.parse(m[1], symbolize_names: true)
|
||
main = arr.find {|v| v[:variant] == "MAIN" }
|
||
open(main[:large])
|
||
end
|
||
end
|