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 end
def get_image_url_from_page(page) def get_image_url_from_page(page)
element = page.search("div.works_display a img").first elements = page.search("div.works_display a img").find_all do |node|
if element node["src"] !~ /source\.pixiv\.net/
element.attr("src").sub(/_[ms]\./, ".") end
if elements.any?
elements.first.attr("src").sub(/_[ms]\./, ".")
else else
nil nil
end end