sources: fix rubocop warnings.
This commit is contained in:
@@ -16,13 +16,13 @@
|
||||
|
||||
module Sources::Strategies
|
||||
class Pawoo < Base
|
||||
HOST = %r!\Ahttps?://(www\.)?pawoo\.net!i
|
||||
IMAGE = %r!\Ahttps?://img\.pawoo\.net/media_attachments/files/(\d+/\d+/\d+)!
|
||||
NAMED_PROFILE = %r!#{HOST}/@(?<artist_name>\w+)!i
|
||||
ID_PROFILE = %r!#{HOST}/web/accounts/(?<artist_id>\d+)!
|
||||
HOST = %r{\Ahttps?://(www\.)?pawoo\.net}i
|
||||
IMAGE = %r{\Ahttps?://img\.pawoo\.net/media_attachments/files/(\d+/\d+/\d+)}
|
||||
NAMED_PROFILE = %r{#{HOST}/@(?<artist_name>\w+)}i
|
||||
ID_PROFILE = %r{#{HOST}/web/accounts/(?<artist_id>\d+)}
|
||||
|
||||
STATUS1 = %r!\A#{HOST}/web/statuses/(?<status_id>\d+)!
|
||||
STATUS2 = %r!\A#{NAMED_PROFILE}/(?<status_id>\d+)!
|
||||
STATUS1 = %r{\A#{HOST}/web/statuses/(?<status_id>\d+)}
|
||||
STATUS2 = %r{\A#{NAMED_PROFILE}/(?<status_id>\d+)}
|
||||
|
||||
def domains
|
||||
["pawoo.net"]
|
||||
@@ -37,15 +37,13 @@ module Sources::Strategies
|
||||
end
|
||||
|
||||
def image_urls
|
||||
if url =~ %r!#{IMAGE}/small/([a-z0-9]+\.\w+)\z!i
|
||||
return ["https://img.pawoo.net/media_attachments/files/#{$1}/original/#{$2}"]
|
||||
if url =~ %r{#{IMAGE}/small/([a-z0-9]+\.\w+)\z}i
|
||||
["https://img.pawoo.net/media_attachments/files/#{$1}/original/#{$2}"]
|
||||
elsif url =~ %r{#{IMAGE}/original/([a-z0-9]+\.\w+)\z}i
|
||||
[url]
|
||||
else
|
||||
api_response.image_urls
|
||||
end
|
||||
|
||||
if url =~ %r!#{IMAGE}/original/([a-z0-9]+\.\w+)\z!i
|
||||
return [url]
|
||||
end
|
||||
|
||||
return api_response.image_urls
|
||||
end
|
||||
|
||||
def page_url
|
||||
@@ -55,16 +53,17 @@ module Sources::Strategies
|
||||
end
|
||||
end
|
||||
|
||||
return super
|
||||
super
|
||||
end
|
||||
|
||||
def profile_url
|
||||
if url =~ PawooApiClient::PROFILE2
|
||||
return "https://pawoo.net/@#{$1}"
|
||||
"https://pawoo.net/@#{$1}"
|
||||
elsif api_response.profile_url.blank?
|
||||
url
|
||||
else
|
||||
api_response.profile_url
|
||||
end
|
||||
|
||||
return url if api_response.profile_url.blank?
|
||||
api_response.profile_url
|
||||
end
|
||||
|
||||
def artist_name
|
||||
@@ -87,10 +86,6 @@ module Sources::Strategies
|
||||
urls.map { |url| url[STATUS1, :status_id] || url[STATUS2, :status_id] }.compact.first
|
||||
end
|
||||
|
||||
def artist_commentary_title
|
||||
nil
|
||||
end
|
||||
|
||||
def artist_commentary_desc
|
||||
api_response.commentary
|
||||
end
|
||||
@@ -99,18 +94,10 @@ module Sources::Strategies
|
||||
api_response.tags
|
||||
end
|
||||
|
||||
def normalizable_for_artist_finder?
|
||||
true
|
||||
end
|
||||
|
||||
def normalize_for_artist_finder
|
||||
profile_url
|
||||
end
|
||||
|
||||
def normalize_for_source
|
||||
artist_name = artist_name_from_url
|
||||
status_id = status_id_from_url
|
||||
return unless status_id.present?
|
||||
return if status_id.blank?
|
||||
|
||||
if artist_name.present?
|
||||
"https://pawoo.net/@#{artist_name}/#{status_id}"
|
||||
@@ -131,7 +118,7 @@ module Sources::Strategies
|
||||
|
||||
def api_response
|
||||
[url, referer_url].each do |x|
|
||||
if client = PawooApiClient.new.get(x)
|
||||
if (client = PawooApiClient.new.get(x))
|
||||
return client
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user