Fix #4293: ArtStation: use 4k images.

Also fixes #4290 (Image replacements: undefined method hostname for nil:NilClass)
This commit is contained in:
evazion
2020-03-03 22:16:16 -06:00
parent b9939c6356
commit 266e4054b0
3 changed files with 35 additions and 33 deletions

View File

@@ -10,7 +10,7 @@ module Downloads
should "download the large image instead" do
file, strategy = @download.download!
assert_equal(517_706, ::File.size(file.path))
assert_equal(1_550_269, ::File.size(file.path))
end
end
@@ -22,7 +22,7 @@ module Downloads
should "not try to download the original" do
file, strategy = @download.download!
assert_equal(449_047, ::File.size(file.path))
assert_equal(382_837, ::File.size(file.path))
end
end
@@ -32,11 +32,11 @@ module Downloads
end
should "return the original file, not the polished file" do
assert_downloaded(517_706, @asset) # polished size: 502_052
assert_downloaded(1_550_269, @asset)
end
should "return the original filesize, not the polished filesize" do
assert_equal(517_706, Downloads::File.new(@asset).size)
assert_equal(1_550_269, Downloads::File.new(@asset).size)
end
end
@@ -49,7 +49,7 @@ module Downloads
should "download the original image instead" do
file, strategy = @download.download!
assert_equal(237_651, ::File.size(file.path))
assert_equal(218_603, ::File.size(file.path))
end
end
end

View File

@@ -8,7 +8,7 @@ module Sources
end
should "get the image url" do
assert_equal("https://cdna.artstation.com/p/assets/images/images/000/705/368/large/jey-rain-one1.jpg", @site.image_url.sub(/\?\d+/, ""))
assert_equal("https://cdn.artstation.com/p/assets/images/images/000/705/368/4k/jey-rain-one1.jpg", @site.image_url.sub(/\?\d+/, ""))
end
should "get the canonical url" do
@@ -39,7 +39,7 @@ module Sources
end
should "get the image url" do
url = "https://cdna.artstation.com/p/assets/images/images/006/066/534/large/yinan-cui-reika.jpg?1495781565"
url = "https://cdn.artstation.com/p/assets/images/images/006/066/534/4k/yinan-cui-reika.jpg?1495781565"
assert_equal(url, @site.image_url)
end
@@ -72,7 +72,7 @@ module Sources
end
should "get the image url" do
url = "https://cdna.artstation.com/p/assets/images/images/000/144/922/large/cassio-yoshiyaki-cody2backup2-yoshiyaki.jpg?1406314198"
url = "https://cdn.artstation.com/p/assets/images/images/000/144/922/4k/cassio-yoshiyaki-cody2backup2-yoshiyaki.jpg?1406314198"
assert_equal(url, @site.image_url)
end
@@ -82,7 +82,7 @@ module Sources
end
end
context "The source site for a http://cdna.artstation.com/p/assets/... url" do
context "The source site for a http://cdn.artstation.com/p/assets/... url" do
setup do
@url = "https://cdna.artstation.com/p/assets/images/images/006/029/978/large/amama-l-z.jpg"
@ref = "https://www.artstation.com/artwork/4BWW2"
@@ -92,7 +92,7 @@ module Sources
should "work" do
site = Sources::Strategies.find(@url, @ref)
assert_equal(@url, site.image_url)
assert_equal("https://cdn.artstation.com/p/assets/images/images/006/029/978/4k/amama-l-z.jpg", site.image_url)
assert_equal("https://amama.artstation.com/projects/4BWW2", site.page_url)
assert_equal("https://amama.artstation.com/projects/4BWW2", site.canonical_url)
assert_equal("https://www.artstation.com/amama", site.profile_url)
@@ -105,7 +105,7 @@ module Sources
should "work" do
site = Sources::Strategies.find(@url)
assert_equal(@url, site.image_url)
assert_equal("https://cdn.artstation.com/p/assets/images/images/006/029/978/4k/amama-l-z.jpg", site.image_url)
assert_nil(site.page_url)
assert_nil(site.profile_url)
assert_nil(site.artist_name)
@@ -115,13 +115,24 @@ module Sources
end
end
context "A 4k asset url" do
context "without a referer" do
should "work" do
site = Sources::Strategies.find("https://cdna.artstation.com/p/assets/images/images/007/253/680/4k/ina-wong-demon-girl-done-ttd-comp.jpg?1504793833")
assert_equal("https://cdn.artstation.com/p/assets/images/images/007/253/680/4k/ina-wong-demon-girl-done-ttd-comp.jpg?1504793833", site.image_url)
assert_nothing_raised { site.to_h }
end
end
end
context "The source site for an ArtStation gallery" do
setup do
@site = Sources::Strategies.find("https://www.artstation.com/artwork/BDxrA")
end
should "get only image urls, not video urls" do
urls = %w[https://cdnb.artstation.com/p/assets/images/images/006/037/253/large/astri-lohne-sjursen-eva.jpg?1495573664]
urls = %w[https://cdn.artstation.com/p/assets/images/images/006/037/253/4k/astri-lohne-sjursen-eva.jpg?1495573664]
assert_equal(urls, @site.image_urls)
end
end