Class: Panchira::PixivResolver

Inherits:
Resolver
  • Object
show all
Defined in:
lib/panchira/resolvers/pixiv_resolver.rb

Constant Summary collapse

URL_REGEXP =
/pixiv\.net\/.*(member_illust.php?.*illust_id=|artworks\/)(\d+)/.freeze

Instance Method Summary collapse

Methods inherited from Resolver

applicable?, #fetch

Constructor Details

#initialize(url, options = nil) ⇒ PixivResolver

Returns a new instance of PixivResolver.



7
8
9
10
11
12
13
14
15
# File 'lib/panchira/resolvers/pixiv_resolver.rb', line 7

def initialize(url, options = nil)
  super(url, options)
  @illust_id = url.slice(URL_REGEXP, 2)

  raw_json = URI.parse("https://www.pixiv.net/ajax/illust/#{@illust_id}").read('User-Agent' => user_agent)
  @json = JSON.parse(raw_json)

  @fetch_raw_image_url = options&.dig(:pixiv, :fetch_raw_image_url)
end