pixiv: fix regression with new user profile urls.
* Update tests to use new Pixiv profile urls. * Fix issue with artist finder not working when given direct image or html page urls.
This commit is contained in:
@@ -27,13 +27,14 @@ class ArtistUrl < ApplicationRecord
|
|||||||
# url = url.sub(%r!^(http://seiga.nicovideo.jp/user/illust/\d+)\?.+!, '\1/')
|
# url = url.sub(%r!^(http://seiga.nicovideo.jp/user/illust/\d+)\?.+!, '\1/')
|
||||||
url = url.sub(%r!^http://pictures.hentai-foundry.com//!, "http://pictures.hentai-foundry.com/")
|
url = url.sub(%r!^http://pictures.hentai-foundry.com//!, "http://pictures.hentai-foundry.com/")
|
||||||
|
|
||||||
# XXX should be handled by pixiv strategy.
|
|
||||||
url = url.sub(%r!\Ahttps?://www\.pixiv\.net/(?:en/)?users/(\d+)\z!i, 'https://www.pixiv.net/member.php?id=\1')
|
|
||||||
|
|
||||||
# the strategy won't always work for twitter because it looks for a status
|
# the strategy won't always work for twitter because it looks for a status
|
||||||
url = url.downcase if url =~ %r!^https?://(?:mobile\.)?twitter\.com!
|
url = url.downcase if url =~ %r!^https?://(?:mobile\.)?twitter\.com!
|
||||||
|
|
||||||
url = Sources::Strategies.find(url).normalize_for_artist_finder
|
url = Sources::Strategies.find(url).normalize_for_artist_finder
|
||||||
|
|
||||||
|
# XXX the Pixiv strategy should implement normalize_for_artist_finder and return the correct url directly.
|
||||||
|
url = url.sub(%r!\Ahttps?://www\.pixiv\.net/(?:en/)?users/(\d+)\z!i, 'https://www.pixiv.net/member.php?id=\1')
|
||||||
|
|
||||||
url = url.gsub(/\/+\Z/, "")
|
url = url.gsub(/\/+\Z/, "")
|
||||||
url = url.gsub(%r!^https://!, "http://")
|
url = url.gsub(%r!^https://!, "http://")
|
||||||
url + "/"
|
url + "/"
|
||||||
|
|||||||
@@ -529,7 +529,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
assert_equal("niceandcool", artist.name)
|
assert_equal("niceandcool", artist.name)
|
||||||
assert_equal("nice_and_cool", artist.other_names_string)
|
assert_equal("nice_and_cool", 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/users/906442")
|
||||||
assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/stacc/niceandcool")
|
assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/stacc/niceandcool")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -540,7 +540,7 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
assert_equal("test_artist", artist.name)
|
assert_equal("test_artist", artist.name)
|
||||||
assert_equal("nice_and_cool niceandcool", artist.other_names_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/users/906442")
|
||||||
assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/stacc/niceandcool")
|
assert_includes(artist.urls.map(&:url), "https://www.pixiv.net/stacc/niceandcool")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ module Sources
|
|||||||
girls_frontline hara_shoutarou hoodie long_hair pantyhose scar skirt
|
girls_frontline hara_shoutarou hoodie long_hair pantyhose scar skirt
|
||||||
twintails ump-45_(girls_frontline) ump-9_(girls_frontline)
|
twintails ump-45_(girls_frontline) ump-9_(girls_frontline)
|
||||||
]
|
]
|
||||||
@profile_url = "https://www.pixiv.net/member.php?id=22528152"
|
@profile_url = "https://www.pixiv.net/users/22528152"
|
||||||
|
|
||||||
@data = { site_name: "konachan.com", preview_url: @prev, image_url: @full, page_url: @page, size: @size, tags: @tags, profile_url: @profile_url }
|
@data = { site_name: "konachan.com", preview_url: @prev, image_url: @full, page_url: @page, size: @size, tags: @tags, profile_url: @profile_url }
|
||||||
assert_source_data_equals(@samp, **@data)
|
assert_source_data_equals(@samp, **@data)
|
||||||
|
|||||||
Reference in New Issue
Block a user