Class: Panchira::PixivNovelResolver

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

Constant Summary collapse

URL_REGEXP =
/pixiv\.net\/novel\/show.php\?id=(\d+)/.freeze

Instance Method Summary collapse

Methods inherited from Resolver

applicable?, #fetch

Constructor Details

#initialize(url, options = nil) ⇒ PixivNovelResolver

Returns a new instance of PixivNovelResolver.



72
73
74
75
76
77
78
# File 'lib/panchira/resolvers/pixiv_resolver.rb', line 72

def initialize(url, options = nil)
  super(url, options)
  @novel_id = url.slice(URL_REGEXP, 1)

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