This commit is contained in:
evazion
2017-06-05 14:00:29 -05:00
parent 71950597e8
commit b3e533f3ff
2 changed files with 16 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ module Downloads
if test_original(original_url)
url = original_url
end
elsif url =~ %r!https?://\w+\.artstation\.com/artwork/!
else
url, headers = rewrite_html_url(url, headers)
end
@@ -22,6 +22,8 @@ module Downloads
end
def rewrite_html_url(url, headers)
return [url, headers] unless Sources::Strategies::ArtStation.url_match?(url)
source = Sources::Site.new(url)
source.get
[source.image_url, headers]

View File

@@ -27,5 +27,18 @@ module Downloads
assert_equal("https://cdna.artstation.com/p/assets/images/images/004/730/278/large/mendel-oh-dragonll.jpg", @download.source)
end
end
context "a download for a https://$artist.artstation.com/projects/$id page" do
setup do
@source = "https://dantewontdie.artstation.com/projects/YZK5q"
@tempfile = Tempfile.new("danbooru-test")
@download = Downloads::File.new(@source, @tempfile.path)
@download.download!
end
should "download the original image instead" do
assert_equal("https://cdna.artstation.com/p/assets/images/images/006/066/534/original/yinan-cui-reika.jpg?1495781565", @download.source)
end
end
end
end