Merge pull request #3242 from evazion/fix-drop-whitecube
Drop Pixiv whitecube support (#2681, #3206).
This commit is contained in:
@@ -65,11 +65,10 @@ module Downloads
|
||||
# http://www.pixiv.net/member_illust.php?mode=big&illust_id=18557054
|
||||
# http://www.pixiv.net/member_illust.php?mode=manga&illust_id=18557054
|
||||
# http://www.pixiv.net/member_illust.php?mode=manga_big&illust_id=18557054&page=1
|
||||
# http://www.pixiv.net/whitecube/user/277898/illust/59182257
|
||||
# Plus this:
|
||||
# i2.pixiv.net/img-inf/img/2014/09/25/00/57/24/46170939_64x64.jpg
|
||||
def rewrite_html_pages(url, headers)
|
||||
if url =~ /illust_id=\d+/i || url =~ %r!pixiv\.net/img-inf/img/!i || url =~ /illust\/\d+/
|
||||
if url =~ /illust_id=\d+/i || url =~ %r!pixiv\.net/img-inf/img/!i
|
||||
return [source.file_url, headers]
|
||||
else
|
||||
return [url, headers]
|
||||
|
||||
@@ -11,7 +11,7 @@ module Sources
|
||||
:rewrite_thumbnails, :illust_id_from_url, :translate_tag, :translated_tags, :to => :strategy
|
||||
|
||||
def self.strategies
|
||||
[Strategies::PixivWhitecube, Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::ArtStation, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr, Strategies::Pawoo]
|
||||
[Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::ArtStation, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr, Strategies::Pawoo]
|
||||
end
|
||||
|
||||
def initialize(url, referer_url: nil)
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
module Sources
|
||||
module Strategies
|
||||
class PixivWhitecube < Base
|
||||
attr_reader :artist_commentary_title, :artist_commentary_desc, :ugoira_frame_data, :ugoira_content_type
|
||||
|
||||
# sample: http://www.pixiv.net/whitecube/user/277898/illust/59182257
|
||||
WHITECUBE_ILLUST = %r!^https?://www\.pixiv\.net/whitecube/user/\d+/illust/\d+!i
|
||||
|
||||
def self.url_match?(url)
|
||||
url =~ WHITECUBE_ILLUST
|
||||
end
|
||||
|
||||
def referer_url
|
||||
@url
|
||||
end
|
||||
|
||||
def site_name
|
||||
"Pixiv Whitecube"
|
||||
end
|
||||
|
||||
def unique_id
|
||||
@pixiv_moniker
|
||||
end
|
||||
|
||||
def fake_referer
|
||||
"http://www.pixiv.net"
|
||||
end
|
||||
|
||||
def normalizable_for_artist_finder?
|
||||
true
|
||||
end
|
||||
|
||||
def normalize_for_artist_finder!
|
||||
"http://img.pixiv.net/img/#{@moniker}/"
|
||||
end
|
||||
|
||||
def get
|
||||
@illust_id = illust_id_from_url
|
||||
@data = query_pixiv_api(@illust_id)
|
||||
|
||||
@artist_name = @data.name
|
||||
@profile_url = "https://www.pixiv.net/whitecube/user/" + @data.user_id.to_s
|
||||
@pixiv_moniker = @data.moniker
|
||||
@zip_url, @ugoira_frame_data, @ugoira_content_type = get_zip_url_from_api(@data)
|
||||
@tags = @data.tags
|
||||
@page_count = @data.page_count
|
||||
@artist_commentary_title = @data.artist_commentary_title
|
||||
@artist_commentary_desc = @data.artist_commentary_desc
|
||||
|
||||
is_manga = @page_count > 1
|
||||
|
||||
if !@zip_url
|
||||
@image_url = @data.pages.first
|
||||
end
|
||||
end
|
||||
|
||||
def file_url
|
||||
@image_url || @zip_url
|
||||
end
|
||||
|
||||
def rewrite_thumbnails(url)
|
||||
url
|
||||
end
|
||||
|
||||
def illust_id_from_url
|
||||
# http://www.pixiv.net/whitecube/user/277898/illust/59182257
|
||||
if url =~ %r!/whitecube/user/\d+/illust/(\d+)!
|
||||
$1
|
||||
|
||||
else
|
||||
raise Sources::Error.new("Couldn't get illust ID from URL: #{url}")
|
||||
end
|
||||
end
|
||||
|
||||
def query_pixiv_api(illust_id)
|
||||
@data ||= PixivApiClient.new.works(illust_id)
|
||||
end
|
||||
|
||||
def get_zip_url_from_api(data)
|
||||
if data.json["metadata"] && data.json["metadata"]["zip_urls"]
|
||||
zip_url = data.json["metadata"]["zip_urls"]["ugoira600x600"].sub("_ugoira600x600.zip", "_ugoira1920x1080.zip")
|
||||
frame_data = data.json["metadata"]["frames"]
|
||||
|
||||
return [zip_url, frame_data, "image/png"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -325,14 +325,6 @@ module Danbooru
|
||||
nil
|
||||
end
|
||||
|
||||
def pixiv_whitecube_login
|
||||
nil
|
||||
end
|
||||
|
||||
def pixiv_whitecube_password
|
||||
nil
|
||||
end
|
||||
|
||||
def tinami_login
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -9,18 +9,6 @@ module Sources
|
||||
end
|
||||
|
||||
context "in all cases" do
|
||||
context "A whitecube page" do
|
||||
setup do
|
||||
@site = Sources::Site.new("https://www.pixiv.net/whitecube/user/277898/illust/59182257")
|
||||
@site.get
|
||||
@image_urls = @site.image_urls
|
||||
end
|
||||
|
||||
should "get all the image urls" do
|
||||
assert_equal(["https://i.pximg.net/img-original/img/2016/09/26/21/30/41/59182257_p0.jpg"], @image_urls)
|
||||
end
|
||||
end
|
||||
|
||||
context "A touch page" do
|
||||
setup do
|
||||
@site = Sources::Site.new("http://touch.pixiv.net/member_illust.php?mode=medium&illust_id=59687915")
|
||||
|
||||
Reference in New Issue
Block a user