Fix #3654: Deviantart commentaries fail fetching.
This commit is contained in:
@@ -58,11 +58,12 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
def artist_name
|
def artist_name
|
||||||
api_metadata.dig(:author, :username)
|
api_metadata.dig(:author, :username).try(&:downcase)
|
||||||
end
|
end
|
||||||
|
|
||||||
def profile_url
|
def profile_url
|
||||||
"https://#{artist_name.downcase}.deviantart.com"
|
return "" if uuid.nil?
|
||||||
|
"https://#{artist_name}.deviantart.com"
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_url
|
def image_url
|
||||||
@@ -118,8 +119,10 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
def page
|
def page
|
||||||
resp = HTTParty.get(normalized_url, Danbooru.config.httparty_options)
|
options = Danbooru.config.httparty_options.deep_merge(format: :plain, headers: { "Accept-Encoding" => "gzip" })
|
||||||
Nokogiri::HTML(resp.body)
|
resp = HTTParty.get(normalized_url, **options)
|
||||||
|
body = Zlib.gunzip(resp.body)
|
||||||
|
Nokogiri::HTML(body)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Scrape UUID from <meta property="da:appurl" content="DeviantArt://deviation/12F08C5D-A3A4-338C-2F1A-7E4E268C0E8B">
|
# Scrape UUID from <meta property="da:appurl" content="DeviantArt://deviation/12F08C5D-A3A4-338C-2F1A-7E4E268C0E8B">
|
||||||
|
|||||||
@@ -20,6 +20,16 @@ module Sources
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "The source for a DeviantArt image url" do
|
||||||
|
should "fetch the source data" do
|
||||||
|
@site = Sources::Site.new("https://pre00.deviantart.net/b5e6/th/pre/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg")
|
||||||
|
|
||||||
|
assert_equal("hideyoshi", @site.artist_name)
|
||||||
|
assert_equal("https://hideyoshi.deviantart.com", @site.profile_url)
|
||||||
|
assert_equal("https://orig00.deviantart.net/9e1f/f/2016/265/3/5/legend_of_galactic_heroes_by_hideyoshi-daihpha.jpg", @site.image_url)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "The source for an DeviantArt artwork page" do
|
context "The source for an DeviantArt artwork page" do
|
||||||
setup do
|
setup do
|
||||||
@site = Sources::Site.new("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")
|
@site = Sources::Site.new("http://noizave.deviantart.com/art/test-post-please-ignore-685436408")
|
||||||
@@ -27,7 +37,7 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "get the image url" do
|
should "get the image url" do
|
||||||
assert_match(%r!https://origin-orig.deviantart.net/7b5b/f/2017/160/c/5/test_post_please_ignore_by_noizave-dbc3a48.png!, @site.image_url)
|
assert_match(%r!https?://origin-orig.deviantart.net/7b5b/f/2017/160/c/5/test_post_please_ignore_by_noizave-dbc3a48.png!, @site.image_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "get the profile" do
|
should "get the profile" do
|
||||||
@@ -86,7 +96,7 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "get the image url" do
|
should "get the image url" do
|
||||||
assert_match(%r!https://origin-orig\.deviantart\.net/cb25/f/2017/160/1/9/hidden_work_by_noizave-dbc3r29\.png!, @site.image_url)
|
assert_match(%r!https?://origin-orig\.deviantart\.net/cb25/f/2017/160/1/9/hidden_work_by_noizave-dbc3r29\.png!, @site.image_url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user