プロジェクト

全般

プロフィール

0001-photo_support-Amazon-URL.patch

cob odo, 2018-10-22 19:38

差分を表示:

core/plugin/photo_support/photo_support.rb
227 227
    img = Plugin::PhotoSupport.d250g2(display_url)
228 228
    open(img) if img
229 229
  end
230

  
231
  # Amazon
232
  amazon_json_regex = %r!'colorImages': { 'initial': (\[.*MAIN.*\])!.freeze
233
  defimageopener('Amazon', %r<\Ahttps?://www\.amazon\.(?:co\.jp|com)/(?:.*/)?(?:dp/|gp/product/)[0-9A-Za-z_]+>) do |url|
234
    html = HTTPClient.new.get_content(url, [], [['User-Agent', 'mikutter']])
235
    m = amazon_json_regex.match(html)
236
    next nil unless m
237
    arr = JSON.parse(m[1], symbolize_names: true)
238
    main = arr.find {|v| v[:variant] == "MAIN" }
239
    open(main[:large])
240
  end
230 241
end
231
-