Class: Panchira::PixivResolver
- 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
-
#initialize(url, options = nil) ⇒ PixivResolver
constructor
A new instance of PixivResolver.
Methods inherited from Resolver
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, = nil) super(url, ) @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 = &.dig(:pixiv, :fetch_raw_image_url) end |