From c3d1c7b6541ddaca689334ff3b2d0719e27f473d Mon Sep 17 00:00:00 2001 From: Wiiplay123 Date: Tue, 25 Apr 2017 20:17:26 -0500 Subject: [PATCH] Fixed deviantArt ripping Uses the data-super-full-img attribute of thumbnails as first attempt to get a full image URL. If that doesn't work (as is the case with mature items), the JSON is used. thumbToFull is still broken in this commit, but shouldn't be needed. --- .../ripper/rippers/DeviantartRipper.java | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java index b170c2e7..7dcd2747 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java @@ -125,7 +125,7 @@ public class DeviantartRipper extends AbstractHTMLRipper { List imageURLs = new ArrayList(); // Iterate over all thumbnails - for (Element thumb : page.select("div.zones-container a.thumb")) { + for (Element thumb : page.select("div.zones-container span.thumb")) { if (isStopped()) { break; } @@ -133,15 +133,33 @@ public class DeviantartRipper extends AbstractHTMLRipper { if (img.attr("transparent").equals("false")) { continue; // a.thumbs to other albums are invisible } - // Get full-sized image via helper methods String fullSize = null; - try { - fullSize = thumbToFull(img.attr("src"), true); - } catch (Exception e) { - logger.info("Attempting to get full size image from " + thumb.attr("href")); - fullSize = smallToFull(img.attr("src"), thumb.attr("href")); - } + if (!thumb.attr("data-super-full-img").isEmpty()) { + fullSize = thumb.attr("data-super-full-img"); + } else { + String spanUrl = thumb.attr("href"); + // id = spanUrl.substring(spanUrl.lastIndexOf('-') + 1) + Elements js = page.select("script[type=\"text/javascript\"]"); + for (Element tag : js) { + if (tag.html().contains("window.__pageload")) { + String script = tag.html(); + script = script.substring(script.indexOf("window.__pageload")); + script = script.substring(script.indexOf(spanUrl.substring(spanUrl.lastIndexOf('-') + 1))); + script = script.substring(script.indexOf("},\"src\":\"") + 9,script.indexOf("\",\"type\"")); // first },"src":"url" after id + fullSize = script.replace("\\/","/"); + break; + } + } + if (fullSize == null) { + try { + fullSize = thumbToFull(img.attr("src"), true); + } catch (Exception e) { + logger.info("Attempting to get full size image from " + thumb.attr("href")); + fullSize = smallToFull(img.attr("src"), thumb.attr("href")); + } + } + } if (fullSize == null) { continue; }