Fix #4030: Artstation artist_name broken for direct image urls.
This commit is contained in:
@@ -20,9 +20,9 @@ module Sources::Strategies
|
|||||||
PROJECT1 = %r!\Ahttps?://www\.artstation\.com/artwork/(?<project_id>[a-z0-9-]+)/?\z!i
|
PROJECT1 = %r!\Ahttps?://www\.artstation\.com/artwork/(?<project_id>[a-z0-9-]+)/?\z!i
|
||||||
PROJECT2 = %r!\Ahttps?://(?<artist_name>[a-z0-9-]+)\.artstation\.com/projects/(?<project_id>[a-z0-9-]+)/?\z!i
|
PROJECT2 = %r!\Ahttps?://(?<artist_name>[a-z0-9-]+)\.artstation\.com/projects/(?<project_id>[a-z0-9-]+)/?\z!i
|
||||||
PROJECT = Regexp.union(PROJECT1, PROJECT2)
|
PROJECT = Regexp.union(PROJECT1, PROJECT2)
|
||||||
ARTIST1 = %r!\Ahttps?://(?<artist_name>[a-z0-9-]+)\.artstation\.com!
|
ARTIST1 = %r{\Ahttps?://(?<artist_name>[a-z0-9-]+)(?<!www)\.artstation\.com/?\z}i
|
||||||
ARTIST2 = %r!\Ahttps?://www\.artstation\.com/artist/(?<artist_name>[a-z0-9-]+)!
|
ARTIST2 = %r{\Ahttps?://www\.artstation\.com/artist/(?<artist_name>[a-z0-9-]+)/?\z}i
|
||||||
ARTIST3 = %r!\Ahttps?://www\.artstation\.com/(?<artist_name>[a-z0-9-]+)!
|
ARTIST3 = %r{\Ahttps?://www\.artstation\.com/(?<artist_name>[a-z0-9-]+)/?\z}i
|
||||||
ARTIST = Regexp.union(ARTIST1, ARTIST2, ARTIST3)
|
ARTIST = Regexp.union(ARTIST1, ARTIST2, ARTIST3)
|
||||||
|
|
||||||
ASSET = %r!\Ahttps?://cdn\w*\.artstation\.com/p/assets/images/images/\d+/\d+/\d+/(?:medium|small|large)/!i
|
ASSET = %r!\Ahttps?://cdn\w*\.artstation\.com/p/assets/images/images/\d+/\d+/\d+/(?:medium|small|large)/!i
|
||||||
@@ -100,8 +100,7 @@ module Sources::Strategies
|
|||||||
# purposes
|
# purposes
|
||||||
|
|
||||||
def artist_name_from_url
|
def artist_name_from_url
|
||||||
urls.map { |url| url[PROJECT, :artist_name] }.compact.first ||
|
urls.map { |url| url[PROJECT, :artist_name] || url[ARTIST, :artist_name] }.compact.first
|
||||||
(urls.map { |url| url[ARTIST, :artist_name] }.compact - ["www"]).first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def project_id
|
def project_id
|
||||||
|
|||||||
Reference in New Issue
Block a user