include default referer url for art station strategy
This commit is contained in:
@@ -5,12 +5,20 @@ module Downloads
|
||||
# example: https://cdnb3.artstation.com/p/assets/images/images/003/716/071/large/aoi-ogata-hate-city.jpg?1476754974
|
||||
if url =~ %r!^https?://cdn\w*\.artstation\.com/p/assets/images/images/\d+/\d+/\d+/(?:medium|small|large)/!
|
||||
url, headers = rewrite_large_url(url, headers)
|
||||
elsif url =~ %r!https?://\w+\.artstation\.com/artwork/!
|
||||
url, headers = rewrite_html_url(url, headers)
|
||||
end
|
||||
|
||||
return [url, headers, data]
|
||||
end
|
||||
|
||||
protected
|
||||
def rewrite_html_url(url, headers)
|
||||
source = Sources::Site.new(url)
|
||||
source.get
|
||||
[source.image_url, headers]
|
||||
end
|
||||
|
||||
def rewrite_large_url(url, headers)
|
||||
# example: https://cdnb3.artstation.com/p/assets/images/images/003/716/071/original/aoi-ogata-hate-city.jpg?1476754974
|
||||
url = url.sub(%r!/(?:medium|small|large)/!, "/original/")
|
||||
|
||||
@@ -7,10 +7,11 @@ module Sources::Strategies
|
||||
end
|
||||
|
||||
def referer_url
|
||||
end
|
||||
|
||||
def tags
|
||||
json["categories"].map {|x| x["name"].downcase.tr(" ", "_")}
|
||||
if @referer_url =~ %r!^https?://\w+\.artstation\.com/artwork/[a-z0-9]+!i
|
||||
@referer_url
|
||||
else
|
||||
@url
|
||||
end
|
||||
end
|
||||
|
||||
def site_name
|
||||
@@ -38,7 +39,7 @@ module Sources::Strategies
|
||||
y, _, _ = image_url_rewriter.rewrite(x["image_url"], nil)
|
||||
y
|
||||
end
|
||||
@tags = json["categories"].map {|x| x["name"].downcase.tr(" ", "_")} if json["categories"]
|
||||
@tags = json["tags"].map {|x| [x.downcase.tr(" ", "_"), "https://www.artstation.com/search?q=" + CGI.escape(x)]} if json["tags"]
|
||||
@artist_commentary_title = json["title"]
|
||||
@artist_commentary_desc = ActionView::Base.full_sanitizer.sanitize(json["description"])
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user