fc2: parse more url types.

This commit is contained in:
evazion
2022-03-18 02:03:00 -05:00
parent 03d2a86ef1
commit 455ee9a52a
2 changed files with 30 additions and 2 deletions

View File

@@ -16,7 +16,8 @@ class Source::URL::Fc2 < Source::URL
# http://silencexs.blog.fc2.com
# http://silencexs.blog106.fc2.com
in username, /blog\d*/, "fc2", "com", *rest
# http://onidocoro.blog14.fc2.com/file/20071003061150.png
in username, /^blog\d*$/, "fc2", "com", *rest
@username = username
@profile_url = "http://#{username}.blog.fc2.com"
@@ -32,10 +33,35 @@ class Source::URL::Fc2 < Source::URL
# http://swordsouls.blog131.fc2blog.net
# http://swordsouls.blog131.fc2blog.us
in username, /blog\d*/, "fc2blog", ("net" | "us") => tld, *rest
in username, /^blog\d*$/, "fc2blog", ("net" | "us") => tld, *rest
@username = username
@profile_url = "http://#{username}.blog.fc2blog.#{tld}"
# http://blog23.fc2.com/m/mosha2/file/uru.jpg
# http://blog.fc2.com/g/genshi/file/20070612a.jpg
in /^blog\d*$/, "fc2", "com", /^\w$/, username, "file", file
@username = username
@profile_url = "http://#{username}.blog.fc2.com"
# http://blog-imgs-63-origin.fc2.com/y/u/u/yuukyuukikansya/140817hijiri02.jpg
# http://blog-imgs-61.fc2.com/o/m/o/omochi6262/20130402080220583.jpg
# http://blog.fc2.com/g/b/o/gbot/20071023195141.jpg
in (/^blog-imgs-\d+(-origin)?$/ | "blog"), "fc2", "com", /^\w$/, /^\w$/, /^\w$/, username, file
@username = username
@profile_url = "http://#{username}.blog.fc2.com"
# http://diary.fc2.com/user/yuuri/img/2005_12/26.jpg
# http://diary1.fc2.com/user/kou_48/img/2006_8/14.jpg
# http://diary.fc2.com/user/kazuharoom/img/2015_5/22.jpg
in /diary\d*$/, "fc2", "com", "user", username, "img", date, file
@username = username
@profile_url = "http://diary.fc2.com/cgi-sys/ed.cgi/#{username}"
# http://diary.fc2.com/cgi-sys/ed.cgi/kazuharoom/?Y=2012&M=10&D=22
in /diary\d*$/, "fc2", "com", "cgi-sys", "ed.cgi", username
@username = username
@profile_url = "http://diary.fc2.com/cgi-sys/ed.cgi/#{username}"
else
end
end

View File

@@ -388,6 +388,8 @@ class ArtistTest < ActiveSupport::TestCase
should "find the artist" do
assert_artist_found("awa", "http://blog71.fc2.com/a/abk00/file/20080220194219.jpg")
assert_artist_found("awa", "http://blog-imgs-71.fc2.com/a/b/k/abk00/20080220194219.jpg")
assert_artist_found("awa", "http://abk00.blog71.fc2.com/file/20080220194219.jpg")
end
should "return nothing for an unknown artist" do