Normalize pixiv artist urls to pixiv member page (fix #3048).
This commit is contained in:
@@ -42,7 +42,7 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
def normalized_for_artist_finder?
|
def normalized_for_artist_finder?
|
||||||
url =~ %r!https?://img\.pixiv\.net/img/#{MONIKER}/?$!i
|
url =~ %r!\Ahttp://www\.pixiv\.net/member\.php\?id=[0-9]+\z/!
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalizable_for_artist_finder?
|
def normalizable_for_artist_finder?
|
||||||
@@ -50,15 +50,10 @@ module Sources
|
|||||||
end
|
end
|
||||||
|
|
||||||
def normalize_for_artist_finder!
|
def normalize_for_artist_finder!
|
||||||
if has_moniker?
|
@illust_id = illust_id_from_url!
|
||||||
moniker = get_moniker_from_url
|
@metadata = get_metadata_from_papi(@illust_id)
|
||||||
else
|
|
||||||
@illust_id = illust_id_from_url!
|
|
||||||
@metadata = get_metadata_from_papi(@illust_id)
|
|
||||||
moniker = @metadata.moniker
|
|
||||||
end
|
|
||||||
|
|
||||||
"http://img.pixiv.net/img/#{moniker}/"
|
"http://www.pixiv.net/member.php?id=#{@metadata.user_id}/"
|
||||||
end
|
end
|
||||||
|
|
||||||
def get
|
def get
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class ArtistsControllerTest < ActionController::TestCase
|
|||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
@artist = FactoryGirl.create(:artist, :notes => "message")
|
@artist = FactoryGirl.create(:artist, :notes => "message")
|
||||||
|
|
||||||
@masao = FactoryGirl.create(:artist, :name => "masao", :url_string => "http://i2.pixiv.net/img04/img/syounen_no_uta/")
|
@masao = FactoryGirl.create(:artist, :name => "masao", :url_string => "http://www.pixiv.net/member.php?id=32777")
|
||||||
@artgerm = FactoryGirl.create(:artist, :name => "artgerm", :url_string => "http://artgerm.deviantart.com/")
|
@artgerm = FactoryGirl.create(:artist, :name => "artgerm", :url_string => "http://artgerm.deviantart.com/")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -204,8 +204,8 @@ class ArtistTest < ActiveSupport::TestCase
|
|||||||
|
|
||||||
context "when finding pixiv artists" do
|
context "when finding pixiv artists" do
|
||||||
setup do
|
setup do
|
||||||
FactoryGirl.create(:artist, :name => "masao",:url_string => "http://i2.pixiv.net/img04/img/syounen_no_uta/")
|
FactoryGirl.create(:artist, :name => "masao",:url_string => "http://www.pixiv.net/member.php?id=32777")
|
||||||
FactoryGirl.create(:artist, :name => "bkub", :url_string => "http://i1.pixiv.net/img01/img/bkubb/")
|
FactoryGirl.create(:artist, :name => "bkub", :url_string => "http://www.pixiv.net/member.php?id=9948")
|
||||||
FactoryGirl.create(:artist, :name => "ryuura", :url_string => "http://www.pixiv.net/member.php?id=8678371")
|
FactoryGirl.create(:artist, :name => "ryuura", :url_string => "http://www.pixiv.net/member.php?id=8678371")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ class ArtistUrlTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "normalize pixiv urls" do
|
should "normalize pixiv urls" do
|
||||||
url = FactoryGirl.create(:artist_url, :url => "http://img55.pixiv.net/img/monet")
|
url = FactoryGirl.create(:artist_url, :url => "https://i.pximg.net/img-original/img/2010/11/30/08/39/58/14901720_p0.png")
|
||||||
assert_equal("http://img55.pixiv.net/img/monet", url.url)
|
assert_equal("https://i.pximg.net/img-original/img/2010/11/30/08/39/58/14901720_p0.png", url.url)
|
||||||
assert_equal("http://img.pixiv.net/img/monet/", url.normalized_url)
|
assert_equal("http://www.pixiv.net/member.php?id=339253/", url.normalized_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "normalize twitter urls" do
|
should "normalize twitter urls" do
|
||||||
|
|||||||
Reference in New Issue
Block a user