Merge pull request #3124 from evazion/fix-artstation-sources
Multiple ArtStation fixes
This commit is contained in:
@@ -57,7 +57,7 @@ module Downloads
|
||||
def after_download(src)
|
||||
src = fix_twitter_sources(src)
|
||||
if options[:referer_url].present?
|
||||
src = set_source_to_referer(src)
|
||||
src = set_source_to_referer(src, options[:referer_url])
|
||||
end
|
||||
src
|
||||
end
|
||||
@@ -137,12 +137,13 @@ module Downloads
|
||||
end
|
||||
end
|
||||
|
||||
def set_source_to_referer(src)
|
||||
def set_source_to_referer(src, referer)
|
||||
if Sources::Strategies::Nijie.url_match?(src) ||
|
||||
Sources::Strategies::Twitter.url_match?(src) ||
|
||||
Sources::Strategies::Tumblr.url_match?(src) ||
|
||||
Sources::Strategies::Pawoo.url_match?(src)
|
||||
strategy = Sources::Site.new(src, :referer_url => options[:referer_url])
|
||||
Sources::Strategies::Pawoo.url_match?(src) ||
|
||||
Sources::Strategies::ArtStation.url_match?(src) || Sources::Strategies::ArtStation.url_match?(referer)
|
||||
strategy = Sources::Site.new(src, :referer_url => referer)
|
||||
strategy.referer_url
|
||||
else
|
||||
src
|
||||
|
||||
@@ -14,12 +14,12 @@ module Sources
|
||||
[Strategies::PixivWhitecube, Strategies::Pixiv, Strategies::NicoSeiga, Strategies::DeviantArt, Strategies::ArtStation, Strategies::Nijie, Strategies::Twitter, Strategies::Tumblr, Strategies::Pawoo]
|
||||
end
|
||||
|
||||
def initialize(url, options = {})
|
||||
def initialize(url, referer_url: nil)
|
||||
@url = url
|
||||
|
||||
Site.strategies.each do |strategy|
|
||||
if strategy.url_match?(url)
|
||||
@strategy = strategy.new(url, options[:referer_url])
|
||||
if strategy.url_match?(url) || strategy.url_match?(referer_url)
|
||||
@strategy = strategy.new(url, referer_url)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,8 +6,11 @@ module Sources::Strategies
|
||||
self.project_id(url).present?
|
||||
end
|
||||
|
||||
# https://www.artstation.com/artwork/04XA4"
|
||||
# https://dantewontdie.artstation.com/projects/YZK5q"
|
||||
# https://www.artstation.com/artwork/cody-from-sf"
|
||||
def self.project_id(url)
|
||||
if url =~ %r!\Ahttps?://\w+\.artstation\.com/(?:artwork|projects)/(?<project_id>[a-z0-9]+)\z!i
|
||||
if url =~ %r!\Ahttps?://\w+\.artstation\.com/(?:artwork|projects)/(?<project_id>[a-z0-9-]+)\z!i
|
||||
$~[:project_id]
|
||||
else
|
||||
nil
|
||||
@@ -51,7 +54,8 @@ module Sources::Strategies
|
||||
@json = JSON.parse(resp.body)
|
||||
@artist_name = json["user"]["username"]
|
||||
@profile_url = json["user"]["permalink"]
|
||||
@image_urls = json["assets"].map do |x|
|
||||
images = json["assets"].select { |asset| asset["asset_type"] == "image" }
|
||||
@image_urls = images.map do |x|
|
||||
y, _, _ = image_url_rewriter.rewrite(x["image_url"], nil)
|
||||
y
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user