class Panchira::PixivResolver
Constants
- URL_REGEXP
Public Class Methods
new(url)
click to toggle source
Calls superclass method
# File lib/panchira/resolvers/pixiv_resolver.rb, line 7 def initialize(url) 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) end
Private Instance Methods
parse_canonical_url()
click to toggle source
# File lib/panchira/resolvers/pixiv_resolver.rb, line 25 def parse_canonical_url "https://pixiv.net/member_illust.php?mode=medium&illust_id=#{@illust_id}" end
parse_image_url()
click to toggle source
# File lib/panchira/resolvers/pixiv_resolver.rb, line 29 def parse_image_url proxy_url = "https://pixiv.cat/#{@illust_id}.jpg" case Net::HTTP.get_response(URI.parse(proxy_url)) when Net::HTTPNotFound proxy_url = "https://pixiv.cat/#{@illust_id}-1.jpg" end proxy_url rescue StandardError @page.css('//meta[property="og:image"]/@content').first.to_s end
parse_title()
click to toggle source
# File lib/panchira/resolvers/pixiv_resolver.rb, line 17 def parse_title @json['body']['title'] end