Add download rewrite for https://$artist.artstation.com/projects/$id.
This commit is contained in:
@@ -8,7 +8,7 @@ module Downloads
|
|||||||
if test_original(original_url)
|
if test_original(original_url)
|
||||||
url = original_url
|
url = original_url
|
||||||
end
|
end
|
||||||
elsif url =~ %r!https?://\w+\.artstation\.com/artwork/!
|
else
|
||||||
url, headers = rewrite_html_url(url, headers)
|
url, headers = rewrite_html_url(url, headers)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,6 +22,8 @@ module Downloads
|
|||||||
end
|
end
|
||||||
|
|
||||||
def rewrite_html_url(url, headers)
|
def rewrite_html_url(url, headers)
|
||||||
|
return [url, headers] unless Sources::Strategies::ArtStation.url_match?(url)
|
||||||
|
|
||||||
source = Sources::Site.new(url)
|
source = Sources::Site.new(url)
|
||||||
source.get
|
source.get
|
||||||
[source.image_url, headers]
|
[source.image_url, headers]
|
||||||
|
|||||||
@@ -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)
|
assert_equal("https://cdna.artstation.com/p/assets/images/images/004/730/278/large/mendel-oh-dragonll.jpg", @download.source)
|
||||||
end
|
end
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user