Source::URL: add profile_url method.

Add a method for converting a source URL into a profile URL. This will
be used for normalizing profile URLs in artist entries.

Also add the ability to parse a few more profile URL formats.
This commit is contained in:
evazion
2022-03-12 03:08:06 -06:00
parent 787b5c8e27
commit 9343f7c912
20 changed files with 154 additions and 26 deletions

View File

@@ -41,7 +41,12 @@ class Source::URL::Fanbox < Source::URL
@work_id = work_id
# https://www.pixiv.net/fanbox/creator/1566167
in "www.pixiv.net", "fanbox", "creator", user_id
# http://www.pixiv.net/fanbox/user/3410642
in "www.pixiv.net", "fanbox", ("creator" | "user"), user_id
@user_id = user_id
# http://www.pixiv.net/fanbox/member.php?user_id=3410642
in "www.pixiv.net", "fanbox", "member.php" if params[:user_id].present?
@user_id = user_id
# https://omu001.fanbox.cc/posts/39714
@@ -71,4 +76,12 @@ class Source::URL::Fanbox < Source::URL
# https://pixiv.pximg.net/c/400x400_90_a2_g5/fanbox/public/images/creator/1566167/profile/BtxSp9MImFhnEZtjEZs2RPqL.jpeg
to_s.gsub(%r{/[cw]/\w+/}, "/") if image_url?
end
def profile_url
if username.present?
"https://#{username}.fanbox.cc"
elsif user_id.present?
"https://www.pixiv.net/fanbox/creator/#{user_id}"
end
end
end