fixes #3728
This commit is contained in:
@@ -84,7 +84,7 @@ module Sources
|
|||||||
@artist_name = @metadata.name
|
@artist_name = @metadata.name
|
||||||
@profile_url = "http://www.pixiv.net/member.php?id=#{@metadata.user_id}"
|
@profile_url = "http://www.pixiv.net/member.php?id=#{@metadata.user_id}"
|
||||||
@pixiv_moniker = @metadata.moniker
|
@pixiv_moniker = @metadata.moniker
|
||||||
@zip_url, @ugoira_frame_data, @ugoira_content_type = get_zip_url_from_page(page)
|
@zip_url, @ugoira_frame_data, @ugoira_content_type = get_zip_url_from_api
|
||||||
@tags = @metadata.tags.map do |tag|
|
@tags = @metadata.tags.map do |tag|
|
||||||
[tag, "https://www.pixiv.net/search.php?s_mode=s_tag_full&#{{word: tag}.to_param}"]
|
[tag, "https://www.pixiv.net/search.php?s_mode=s_tag_full&#{{word: tag}.to_param}"]
|
||||||
end
|
end
|
||||||
@@ -95,8 +95,8 @@ module Sources
|
|||||||
is_manga = @page_count > 1
|
is_manga = @page_count > 1
|
||||||
|
|
||||||
if !@zip_url
|
if !@zip_url
|
||||||
@image_url = get_image_url_from_page(page, @page_count > 1)
|
page = manga_page_from_url(@url).to_i
|
||||||
#@image_url = image_urls.first
|
@image_url = image_urls[page]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -284,6 +284,31 @@ module Sources
|
|||||||
thumbnail_url = element.attr("src") || element.attr("data-src")
|
thumbnail_url = element.attr("src") || element.attr("data-src")
|
||||||
return rewrite_thumbnails(thumbnail_url, is_manga)
|
return rewrite_thumbnails(thumbnail_url, is_manga)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if page.body =~ /"original":"(https:.+?)"/
|
||||||
|
return $1.gsub(/\\\//, '/')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_zip_url_from_api
|
||||||
|
if @metadata.pages.is_a?(Hash) && @metadata.pages["ugoira600x600"]
|
||||||
|
zip_url = @metadata.pages["ugoira600x600"].sub("_ugoira600x600.zip", "_ugoira1920x1080.zip")
|
||||||
|
frame_data = @metadata.json["metadata"]["frames"]
|
||||||
|
content_type = nil
|
||||||
|
|
||||||
|
case @metadata.json["image_urls"].to_s
|
||||||
|
when /\.jpg/
|
||||||
|
content_type = "image/jpeg"
|
||||||
|
|
||||||
|
when /\.png/
|
||||||
|
content_type = "image/png"
|
||||||
|
|
||||||
|
when /\.gif/
|
||||||
|
content_type = "image/gif"
|
||||||
|
end
|
||||||
|
|
||||||
|
return [zip_url, frame_data, content_type]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_zip_url_from_page(page)
|
def get_zip_url_from_page(page)
|
||||||
|
|||||||
@@ -21,7 +21,12 @@ module Downloads
|
|||||||
|
|
||||||
should "capture the data" do
|
should "capture the data" do
|
||||||
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @download.source)
|
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @download.source)
|
||||||
assert_equal([{"file"=>"000000.jpg", "delay"=>125}, {"file"=>"000001.jpg", "delay"=>125}], @download.data[:ugoira_frame_data])
|
assert_equal(2, @download.data[:ugoira_frame_data].size)
|
||||||
|
if @download.data[:ugoira_frame_data][0]["file"]
|
||||||
|
assert_equal([{"file"=>"000000.jpg", "delay"=>125}, {"file"=>"000001.jpg", "delay"=>125}], @download.data[:ugoira_frame_data])
|
||||||
|
else
|
||||||
|
assert_equal([{"delay_msec"=>125}, {"delay_msec"=>125}], @download.data[:ugoira_frame_data])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -194,7 +194,7 @@ class PostReplacementTest < ActiveSupport::TestCase
|
|||||||
assert_equal("cad1da177ef309bf40a117c17b8eecf5", Digest::MD5.file(@post.file).hexdigest)
|
assert_equal("cad1da177ef309bf40a117c17b8eecf5", Digest::MD5.file(@post.file).hexdigest)
|
||||||
|
|
||||||
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @post.source)
|
assert_equal("https://i.pximg.net/img-zip-ugoira/img/2017/04/04/08/57/38/62247364_ugoira1920x1080.zip", @post.source)
|
||||||
assert_equal([{"file"=>"000000.jpg", "delay"=>125}, {"file"=>"000001.jpg", "delay"=>125}], @post.pixiv_ugoira_frame_data.data)
|
assert_equal([{"delay_msec"=>125}, {"delay_msec"=>125}], @post.pixiv_ugoira_frame_data.data)
|
||||||
rescue Net::OpenTimeout
|
rescue Net::OpenTimeout
|
||||||
skip "Remote connection to Pixiv failed"
|
skip "Remote connection to Pixiv failed"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -55,7 +55,12 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "capture the frame data" do
|
should "capture the frame data" do
|
||||||
assert_equal([{"file"=>"000000.jpg", "delay"=>125}, {"file"=>"000001.jpg", "delay"=>125}], @site.ugoira_frame_data)
|
assert_equal(2, @site.ugoira_frame_data.size)
|
||||||
|
if @site.ugoira_frame_data[0]["file"]
|
||||||
|
assert_equal([{"file"=>"000000.jpg", "delay"=>125}, {"file"=>"000001.jpg", "delay"=>125}], @site.ugoira_frame_data)
|
||||||
|
else
|
||||||
|
assert_equal([{"delay_msec"=>125}, {"delay_msec"=>125}], @site.ugoira_frame_data)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user