Fixing DeviantArt ripper when no Download box is found

This commit is contained in:
4pr0n 2015-03-30 01:32:27 -07:00
parent d92463ee57
commit feb82b2dc5

View File

@ -287,13 +287,24 @@ public class DeviantartRipper extends AbstractHTMLRipper {
cookies.putAll(resp.cookies()); cookies.putAll(resp.cookies());
// Try to find the download button // Try to find the download button
Elements els = resp.parse().select("a.dev-page-download"); Document doc = resp.parse();
if (els.size() == 0) { Elements els = doc.select("a.dev-page-download");
throw new IOException("No download page found"); if (els.size() > 0) {
// Full-size image
String fsimage = els.get(0).attr("href");
logger.info("Found download page: " + fsimage);
return fsimage;
} }
// Full-size image
String fsimage = els.get(0).attr("href"); // Get the largest resolution image on the page
return fsimage; els = doc.select("img.dev-content-full");
if (els.size() > 0) {
// Large image
String fsimage = els.get(0).attr("src");
logger.info("Found large-scale: " + fsimage);
return fsimage;
}
throw new IOException("No download page found");
} catch (IOException ioe) { } catch (IOException ioe) {
try { try {
logger.info("Failed to get full size download image at " + page + " : '" + ioe.getMessage() + "'"); logger.info("Failed to get full size download image at " + page + " : '" + ioe.getMessage() + "'");