Merge pull request #4457 from lllusion3469/fix_da

Fix Deviantart
This commit is contained in:
evazion
2020-05-11 16:22:48 -05:00
committed by GitHub
8 changed files with 282 additions and 70 deletions

View File

@@ -205,6 +205,7 @@ class ArtistTest < ActiveSupport::TestCase
context "when finding deviantart artists" do
setup do
skip "DeviantArt API keys not set" unless Danbooru.config.deviantart_client_id.present?
FactoryBot.create(:artist, :name => "artgerm", :url_string => "http://artgerm.deviantart.com/")
FactoryBot.create(:artist, :name => "trixia", :url_string => "http://trixdraws.deviantart.com/")
end

View File

@@ -2,6 +2,11 @@ require 'test_helper'
module Sources
class DeviantArtTest < ActiveSupport::TestCase
def setup
super
skip "DeviantArt API keys not set" unless Danbooru.config.deviantart_client_id.present?
end
context "A page url" do
setup do
@site = Sources::Strategies.find("https://www.deviantart.com/aeror404/art/Holiday-Elincia-424551484")
@@ -239,6 +244,36 @@ module Sources
end
end
context "The source for a non-downloadable animated gif with id<=790677560" do
should "return working image url" do
@site = Sources::Strategies.find("https://www.deviantart.com/heartgear/art/Silent-Night-579982816")
# md5: 62caac1863aa264a56d548b4b7607097
assert_match(%r!\Ahttps://images-wixmp-ed30a86b8c4ca887773594c2\.wixmp\.com/f/ea95be00-c5aa-4063-bd55-f5a9183912f7/d9lb1ls-7d625444-0003-4123-bf00-274737ca7fdd.gif\?token=!, @site.image_url)
assert_downloaded(350_156, @site.image_url)
end
end
context "The source for a non-downloadable flash file" do
should "return working image url" do
@site = Sources::Strategies.find("https://www.deviantart.com/heartgear/art/SL-40v3-522007633")
# md5: 6adf1a3d532f898f44cf9948cbc7db7d
assert_match(%r!\Ahttps://api-da\.wixmp\.com/_api/download/file\?downloadToken=!, @site.image_url)
assert_downloaded(3_496_110, @site.image_url)
end
end
context "The source for a non-downloadable video file" do
should "return working image url" do
@site = Sources::Strategies.find("https://www.deviantart.com/gs-mantis/art/Chen-Goes-Fishing-505847233")
# md5: 344ac2b9fd5a87982af4b648aa2b2b0d
assert_equal("https://wixmp-ed30a86b8c4ca887773594c2.wixmp.com/v/mp4/fe046bc7-4d68-4699-96c1-19aa464edff6/d8d6281-91959e92-214f-4b2d-a138-ace09f4b6d09.1080p.8e57939eba634743a9fa41185e398d00.mp4", @site.image_url)
assert_downloaded(9_739_947, @site.image_url)
end
end
context "The source for an DeviantArt artwork page" do
setup do
@site = Sources::Strategies.find("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")

View File

@@ -0,0 +1,56 @@
require 'test_helper'
module Sources
class StashTest < ActiveSupport::TestCase
def setup
super
skip "DeviantArt API keys not set" unless Danbooru.config.deviantart_client_id.present?
end
context "A https://sta.sh/:id page url" do
should "work" do
@site = Sources::Strategies.find("https://sta.sh/0wxs31o7nn2")
assert_equal("noizave", @site.artist_name)
assert_equal("https://www.deviantart.com/noizave", @site.profile_url)
assert_equal("A pepe", @site.artist_commentary_title)
assert_equal("This is a test.", @site.artist_commentary_desc)
assert_equal("https://sta.sh/0wxs31o7nn2", @site.page_url)
assert_equal("https://sta.sh/0wxs31o7nn2", @site.canonical_url)
assert_match(%r!\Ahttps://api-da\.wixmp\.com/_api/download/file\?downloadToken=!, @site.image_url)
end
end
context "A https://orig00.deviantart.net/* image url" do
context "with a https://sta.sh/:id referer" do
should "work" do
@site = Sources::Strategies.find("https://orig00.deviantart.net/0fd2/f/2018/252/9/c/a_pepe_by_noizave-dcmga0s.png", "https://sta.sh/0wxs31o7nn2")
assert_equal("noizave", @site.artist_name)
assert_equal("https://www.deviantart.com/noizave", @site.profile_url)
assert_equal("A pepe", @site.artist_commentary_title)
assert_equal("This is a test.", @site.artist_commentary_desc)
assert_equal("https://sta.sh/0wxs31o7nn2", @site.page_url)
assert_equal("https://sta.sh/0wxs31o7nn2", @site.canonical_url)
assert_match(%r!\Ahttps://api-da\.wixmp\.com/_api/download/file\?downloadToken=!, @site.image_url)
end
end
context "without a referer" do
should "use the base deviantart strategy" do
@site = Sources::Strategies.find("https://orig00.deviantart.net/0fd2/f/2018/252/9/c/a_pepe_by_noizave-dcmga0s.png")
# if all we have is the image url, then we can't tell that this is really a sta.sh image.
assert_equal("Deviant Art", @site.site_name)
# this is the wrong page, but there's no way to know the correct sta.sh page without the referer.
assert_equal("https://www.deviantart.com/noizave/art/A-Pepe-763305148", @site.page_url)
end
end
end
end
end