diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index b5b285c3a..63f9290a6 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -26,7 +26,7 @@ module Sources agent.get(URI.parse(normalized_url)) do |page| @artist_name, @profile_url = get_profile_from_page(page) @image_url = get_image_url_from_page(page) - @tags = [] + @tags = get_tags_from_page(page) end end @@ -62,6 +62,14 @@ module Sources end end + def get_tags_from_page(page) + links = page.search("a.discoverytag") + + links.map do |node| + [node.attr("data-canonical-tag"), node.attr("href")] + end + end + def normalized_url @normalized_url ||= begin if url =~ %r{\Ahttps?://(?:fc|th|pre|orig|img)\d{2}\.deviantart\.net/.+/[a-z0-9_]*_by_[a-z0-9_]+-d([a-z0-9]+)\.}i