From 2129e60b2b98312ecaa46409ed9852e9123ca7b4 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 27 Dec 2018 15:03:11 -0600 Subject: [PATCH] pixiv: include stacc url in new artist entries (#4028). --- app/logical/sources/strategies/pixiv.rb | 13 +++++++++++++ test/unit/artist_test.rb | 8 +++++--- test/unit/sources/pixiv_test.rb | 11 +++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb index 664d95936..7c99bde23 100644 --- a/app/logical/sources/strategies/pixiv.rb +++ b/app/logical/sources/strategies/pixiv.rb @@ -109,12 +109,25 @@ module Sources nil end + def stacc_url + return nil if moniker.blank? + "https://www.pixiv.net/stacc/#{moniker}" + end + + def profile_urls + [profile_url, stacc_url].compact + end + def artist_name metadata.name rescue PixivApiClient::BadIDError nil end + def other_names + [artist_name, moniker].compact.uniq + end + def artist_commentary_title metadata.artist_commentary_title rescue PixivApiClient::BadIDError diff --git a/test/unit/artist_test.rb b/test/unit/artist_test.rb index 7bc3f9cc5..e84c4b370 100644 --- a/test/unit/artist_test.rb +++ b/test/unit/artist_test.rb @@ -558,7 +558,8 @@ class ArtistTest < ActiveSupport::TestCase assert_equal("niceandcool", artist.name) assert_equal("nice_and_cool", artist.other_names_string) - assert_equal("https://www.pixiv.net/member.php?id=906442", artist.url_string) + assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/member.php?id=906442") + assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/stacc/niceandcool") end should "fetch the defaults from the given tag" do @@ -567,8 +568,9 @@ class ArtistTest < ActiveSupport::TestCase artist = Artist.new_with_defaults(name: "test_artist") assert_equal("test_artist", artist.name) - assert_equal("nice_and_cool", artist.other_names_string) - assert_equal("https://www.pixiv.net/member.php?id=906442", artist.url_string) + assert_equal("nice_and_cool niceandcool", artist.other_names_string) + assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/member.php?id=906442") + assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/stacc/niceandcool") end end end diff --git a/test/unit/sources/pixiv_test.rb b/test/unit/sources/pixiv_test.rb index 9622fd22d..cdfe221b0 100644 --- a/test/unit/sources/pixiv_test.rb +++ b/test/unit/sources/pixiv_test.rb @@ -278,6 +278,17 @@ module Sources assert_equal(["fate/grand_order"], source.translated_tags.map(&:name)) end end + + context "fetching the artist data" do + should "get the artist names and profile urls" do + source = get_source("https://www.pixiv.net/member_illust.php?mode=medium&illust_id=65981746") + + assert_equal("uroobnad", source.tag_name) + assert_equal(["uroobnad"], source.other_names) + assert_includes(source.profile_urls, "https://www.pixiv.net/member.php?id=696859") + assert_includes(source.profile_urls, "https://www.pixiv.net/stacc/uroobnad") + end + end end end end