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

@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Source::URL::Weibo < Source::URL
attr_reader :full_image_url
attr_reader :full_image_url, :artist_short_id, :artist_long_id
def self.match?(url)
url.domain.in?(["weibo.com", "weibo.cn", "sinaimg.cn"])
@@ -63,18 +63,12 @@ class Source::URL::Weibo < Source::URL
full_image_url.present?
end
def profile_urls
[profile_short_url, profile_long_url].compact
end
def profile_short_url
return if @artist_short_id.blank?
"https://www.weibo.com/u/#{@artist_short_id}"
end
def profile_long_url
return if @artist_long_id.blank?
"https://www.weibo.com/p/#{@artist_long_id}"
def profile_url
if artist_short_id.present?
"https://www.weibo.com/u/#{artist_short_id}"
elsif artist_long_id.present?
"https://www.weibo.com/p/#{artist_long_id}"
end
end
def mobile_url