This commit is contained in:
r888888888
2017-09-14 11:37:42 -07:00
parent 3ffd871e8a
commit d12f082f9a
4 changed files with 26 additions and 4 deletions

View File

@@ -60,6 +60,10 @@ class Artist < ApplicationRecord
memoize :domains
end
def sorted_urls
urls.sort {|a, b| a.priority <=> b.priority}
end
def url_array
urls.map(&:url)
end

View File

@@ -53,6 +53,24 @@ class ArtistUrl < ApplicationRecord
url = url.gsub(/^http:\/\/i\d+\.pixiv\.net\/img\d+/, "http://*.pixiv.net/img*")
end
def priority
if normalized_url =~ /pixiv\.net\/member\.php/
10
elsif normalized_url =~ /seiga\.nicovideo\.jp\/user\/illust/
10
elsif normalized_url =~ /twitter\.com/ && normalized_url !~ /status/
10
elsif normalized_url =~ /tumblr|patreon|deviantart|artstation/
20
else
100
end
end
def normalize
if !Sources::Site.new(normalized_url).normalized_for_artist_finder?
self.normalized_url = self.class.normalize(url)