pixiv: fix preview_urls to use correct url (#3891).

This commit is contained in:
evazion
2018-09-11 23:55:46 -05:00
parent d5c7de84a3
commit 37fc215d75
2 changed files with 5 additions and 2 deletions

View File

@@ -12,6 +12,7 @@ module Sources
IMG = %r!(?:\A(?:https?://)?img[0-9]*\.pixiv\.net)!
PXIMG = %r!(?:\A(?:https?://)?i\.pximg\.net)!
TOUCH = %r!(?:\A(?:https?://)?touch\.pixiv\.net)!
ORIG_IMAGE = %r!#{PXIMG}/img-original/img/(?<date>\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2})/(?<illust_id>\d+)_p(?<page>\d+)\.#{EXT}\z!i
STACC_PAGE = %r!\A#{WEB}/stacc/#{MONIKER}/?\z!i
NOVEL_PAGE = %r!(?:\Ahttps?://www\.pixiv\.net/novel/show\.php\?id=(\d+))!
FANBOX_ACCOUNT = %r!(?:\Ahttps?://www\.pixiv\.net/fanbox/creator/\d+\z)!
@@ -52,7 +53,9 @@ module Sources
def preview_urls
image_urls.map do |x|
x.sub(%r!pximg\.net/img-original/img!, "pximg.net/c/240x240/img-master/img")
x.sub(ORIG_IMAGE) do
"https://i.pximg.net/c/240x240/img-master/img/#{$~[:date]}/#{$~[:illust_id]}_p#{$~[:page]}_master1200.jpg"
end
end
end

View File

@@ -103,7 +103,7 @@ module Sources
end
should "get the preview size image url" do
assert_equal("https://i.pximg.net/c/240x240/img-master/img/2017/11/21/05/12/37/65981735_p0.jpg", @site.preview_url)
assert_equal("https://i.pximg.net/c/240x240/img-master/img/2017/11/21/05/12/37/65981735_p0_master1200.jpg", @site.preview_url)
end
should "get the page count" do