If the yande.re or konachan.com post has a source from a supported site, for example Pixiv or Twitter, then delegate the artist and commentary lookup to that substrategy. Only do this for sources from recognized sites, not the null strategy.
28 lines
695 B
Ruby
28 lines
695 B
Ruby
module Sources
|
|
module Strategies
|
|
def self.all
|
|
return [
|
|
Strategies::Pixiv,
|
|
Strategies::NicoSeiga,
|
|
Strategies::Twitter,
|
|
Strategies::Stash, # must come before DeviantArt
|
|
Strategies::DeviantArt,
|
|
Strategies::Tumblr,
|
|
Strategies::ArtStation,
|
|
Strategies::Nijie,
|
|
Strategies::Pawoo,
|
|
Strategies::Moebooru,
|
|
]
|
|
end
|
|
|
|
def self.find(url, referer=nil, default: Strategies::Null)
|
|
strategy = all.detect { |strategy| strategy.match?(url, referer) } || default
|
|
strategy&.new(url, referer)
|
|
end
|
|
|
|
def self.canonical(url, referer)
|
|
find(url, referer).canonical_url
|
|
end
|
|
end
|
|
end
|