pixiv: fix failure to upload bad pixiv id images (fix #4031)
Bug: Uploading bad pixiv id images failed because the pixiv strategy raised a BadIDError exception when the upload service checked for the ugoira frame data.
This commit is contained in:
@@ -326,6 +326,8 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
return metadata.moniker
|
return metadata.moniker
|
||||||
|
rescue PixivApiClient::BadIDError
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
memoize :moniker
|
memoize :moniker
|
||||||
|
|
||||||
@@ -344,6 +346,8 @@ module Sources
|
|||||||
|
|
||||||
def ugoira_frame_data
|
def ugoira_frame_data
|
||||||
return metadata.json.dig("metadata", "frames")
|
return metadata.json.dig("metadata", "frames")
|
||||||
|
rescue PixivApiClient::BadIDError
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
memoize :ugoira_frame_data
|
memoize :ugoira_frame_data
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ class UploadService
|
|||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
|
|
||||||
if download.data[:ugoira_frame_data]
|
if download.data[:ugoira_frame_data].present?
|
||||||
upload.context = {
|
upload.context = {
|
||||||
"ugoira" => {
|
"ugoira" => {
|
||||||
"frame_data" => download.data[:ugoira_frame_data],
|
"frame_data" => download.data[:ugoira_frame_data],
|
||||||
|
|||||||
@@ -168,10 +168,13 @@ module Sources
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "fetching source data for a deleted work" do
|
context "A deleted pixiv post" do
|
||||||
should "return the same url" do
|
should "not fail when fetching the source data" do
|
||||||
get_source("https://i.pximg.net/img-original/img/2017/11/22/01/06/44/65991677_p0.png")
|
@source = "https://i.pximg.net/img-original/img/2018/12/30/01/04/55/72373728_p0.png"
|
||||||
assert_equal(["https://i.pximg.net/img-original/img/2017/11/22/01/06/44/65991677_p0.png"], @site.image_urls)
|
get_source(@source)
|
||||||
|
|
||||||
|
assert_equal([@source], @site.image_urls)
|
||||||
|
assert_nothing_raised { @site.to_h }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user