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

@@ -110,6 +110,27 @@ module Source
end
end
# Convert the current URL into a profile URL, or return nil if it's not
# possible to get the profile URL from the current URL.
#
# URLs in artist entries will be normalized into this form.
#
# Some sites may have multiple profile URLs, for example if the site has
# both usernames and user IDs. This may return different profile URLs,
# depending on whether the current URL has the username or the user ID.
#
# Examples:
#
# * https://www.pixiv.net/member.php?id=9948
# * https://www.pixiv.net/stacc/bkubb
# * https://twitter.com/bkub_comic
# * https://twitter.com/intent/user?user_id=889592953
#
# @return [String, nil]
def profile_url
nil
end
protected def initialize(...)
super(...)
parse