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
|
||||
|
||||
return metadata.moniker
|
||||
rescue PixivApiClient::BadIDError
|
||||
nil
|
||||
end
|
||||
memoize :moniker
|
||||
|
||||
@@ -344,6 +346,8 @@ module Sources
|
||||
|
||||
def ugoira_frame_data
|
||||
return metadata.json.dig("metadata", "frames")
|
||||
rescue PixivApiClient::BadIDError
|
||||
nil
|
||||
end
|
||||
memoize :ugoira_frame_data
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ class UploadService
|
||||
retry
|
||||
end
|
||||
|
||||
if download.data[:ugoira_frame_data]
|
||||
if download.data[:ugoira_frame_data].present?
|
||||
upload.context = {
|
||||
"ugoira" => {
|
||||
"frame_data" => download.data[:ugoira_frame_data],
|
||||
|
||||
@@ -168,10 +168,13 @@ module Sources
|
||||
end
|
||||
end
|
||||
|
||||
context "fetching source data for a deleted work" do
|
||||
should "return the same url" do
|
||||
get_source("https://i.pximg.net/img-original/img/2017/11/22/01/06/44/65991677_p0.png")
|
||||
assert_equal(["https://i.pximg.net/img-original/img/2017/11/22/01/06/44/65991677_p0.png"], @site.image_urls)
|
||||
context "A deleted pixiv post" do
|
||||
should "not fail when fetching the source data" do
|
||||
@source = "https://i.pximg.net/img-original/img/2018/12/30/01/04/55/72373728_p0.png"
|
||||
get_source(@source)
|
||||
|
||||
assert_equal([@source], @site.image_urls)
|
||||
assert_nothing_raised { @site.to_h }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user