プロジェクト

全般

プロフィール

提案 #1301 » 0001-photo_support-Amazon-URL.patch

cob odo, 2018-10-22 19:38

差分を表示:

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
    (1-1/1)