Prevent pixiv downloader from returning wrong image

This commit is contained in:
Toks
2014-06-25 11:14:08 -04:00
parent 18ac8124ce
commit 224da8a7da

View File

@@ -50,9 +50,12 @@ module Sources
end
def get_image_url_from_page(page)
element = page.search("div.works_display a img").first
if element
element.attr("src").sub(/_[ms]\./, ".")
elements = page.search("div.works_display a img").find_all do |node|
node["src"] !~ /source\.pixiv\.net/
end
if elements.any?
elements.first.attr("src").sub(/_[ms]\./, ".")
else
nil
end