pixiv: fix preview_urls for ugoiras (#3891).
This commit is contained in:
@@ -5,6 +5,7 @@ module Sources
|
|||||||
class Pixiv < Base
|
class Pixiv < Base
|
||||||
MONIKER = %r!(?:[a-zA-Z0-9_-]+)!
|
MONIKER = %r!(?:[a-zA-Z0-9_-]+)!
|
||||||
PROFILE = %r!\Ahttps?://www\.pixiv\.net/member\.php\?id=[0-9]+\z!
|
PROFILE = %r!\Ahttps?://www\.pixiv\.net/member\.php\?id=[0-9]+\z!
|
||||||
|
DATE = %r!(?<date>\d{4}/\d{2}/\d{2}/\d{2}/\d{2}/\d{2})!i
|
||||||
EXT = %r!(?:jpg|jpeg|png|gif)!i
|
EXT = %r!(?:jpg|jpeg|png|gif)!i
|
||||||
|
|
||||||
WEB = %r!(?:\A(?:https?://)?www\.pixiv\.net)!
|
WEB = %r!(?:\A(?:https?://)?www\.pixiv\.net)!
|
||||||
@@ -12,7 +13,8 @@ module Sources
|
|||||||
IMG = %r!(?:\A(?:https?://)?img[0-9]*\.pixiv\.net)!
|
IMG = %r!(?:\A(?:https?://)?img[0-9]*\.pixiv\.net)!
|
||||||
PXIMG = %r!(?:\A(?:https?://)?i\.pximg\.net)!
|
PXIMG = %r!(?:\A(?:https?://)?i\.pximg\.net)!
|
||||||
TOUCH = %r!(?:\A(?:https?://)?touch\.pixiv\.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
|
UGOIRA = %r!#{PXIMG}/img-zip-ugoira/img/#{DATE}/(?<illust_id>\d+)_ugoira1920x1080\.zip\z!i
|
||||||
|
ORIG_IMAGE = %r!#{PXIMG}/img-original/img/#{DATE}/(?<illust_id>\d+)_p(?<page>\d+)\.#{EXT}\z!i
|
||||||
STACC_PAGE = %r!\A#{WEB}/stacc/#{MONIKER}/?\z!i
|
STACC_PAGE = %r!\A#{WEB}/stacc/#{MONIKER}/?\z!i
|
||||||
NOVEL_PAGE = %r!(?:\Ahttps?://www\.pixiv\.net/novel/show\.php\?id=(\d+))!
|
NOVEL_PAGE = %r!(?:\Ahttps?://www\.pixiv\.net/novel/show\.php\?id=(\d+))!
|
||||||
FANBOX_ACCOUNT = %r!(?:\Ahttps?://www\.pixiv\.net/fanbox/creator/\d+\z)!
|
FANBOX_ACCOUNT = %r!(?:\Ahttps?://www\.pixiv\.net/fanbox/creator/\d+\z)!
|
||||||
@@ -52,9 +54,14 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
def preview_urls
|
def preview_urls
|
||||||
image_urls.map do |x|
|
image_urls.map do |url|
|
||||||
x.sub(ORIG_IMAGE) do
|
case url
|
||||||
|
when ORIG_IMAGE
|
||||||
"https://i.pximg.net/c/240x240/img-master/img/#{$~[:date]}/#{$~[:illust_id]}_p#{$~[:page]}_master1200.jpg"
|
"https://i.pximg.net/c/240x240/img-master/img/#{$~[:date]}/#{$~[:illust_id]}_p#{$~[:page]}_master1200.jpg"
|
||||||
|
when UGOIRA
|
||||||
|
"https://i.pximg.net/c/240x240/img-master/img/#{$~[:date]}/#{$~[:illust_id]}_master1200.jpg"
|
||||||
|
else
|
||||||
|
url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ module Sources
|
|||||||
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @site.file_url)
|
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @site.file_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "get the preview url" do
|
||||||
|
assert_equal("https://i.pximg.net/c/240x240/img-master/img/2017/04/04/08/57/38/62247364_master1200.jpg", @site.preview_url)
|
||||||
|
end
|
||||||
|
|
||||||
should "capture the frame data" do
|
should "capture the frame data" do
|
||||||
assert_equal(2, @site.ugoira_frame_data.size)
|
assert_equal(2, @site.ugoira_frame_data.size)
|
||||||
if @site.ugoira_frame_data[0]["file"]
|
if @site.ugoira_frame_data[0]["file"]
|
||||||
|
|||||||
Reference in New Issue
Block a user