diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java index 300e8a64..cdab1664 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java @@ -16,7 +16,7 @@ import com.rarchives.ripme.utils.Utils; * Simplified ripper, designed for ripping from sites by parsing HTML. */ public abstract class AbstractHTMLRipper extends AlbumRipper { - + public AbstractHTMLRipper(URL url) throws IOException { super(url); } @@ -30,7 +30,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { } public abstract List getURLsFromPage(Document page); public List getDescriptionsFromPage(Document doc) throws IOException { - throw new IOException("getDescriptionsFromPage not implemented"); // Do I do this or make an abstract function? + throw new IOException("getDescriptionsFromPage not implemented"); // Do I do this or make an abstract function? } public abstract void downloadURL(URL url, int index); public DownloadThreadPool getThreadPool() { @@ -45,16 +45,16 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { public boolean canRip(URL url) { return url.getHost().endsWith(getDomain()); } - + @Override public URL sanitizeURL(URL url) throws MalformedURLException { return url; } public boolean hasDescriptionSupport() { - return false; + return false; } public String[] getDescription(String url,Document page) throws IOException { - throw new IOException("getDescription not implemented"); // Do I do this or make an abstract function? + throw new IOException("getDescription not implemented"); // Do I do this or make an abstract function? } public int descSleepTime() { return 100; @@ -66,7 +66,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { logger.info("Retrieving " + this.url); sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm()); Document doc = getFirstPage(); - + while (doc != null) { List imageURLs = getURLsFromPage(doc); // Remove all but 1 image @@ -79,7 +79,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { if (imageURLs.size() == 0) { throw new IOException("No images found at " + doc.location()); } - + for (String imageURL : imageURLs) { index += 1; logger.debug("Found image url #" + index + ": " + imageURL); @@ -90,15 +90,15 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { } if (hasDescriptionSupport() && Utils.getConfigBoolean("descriptions.save", false)) { logger.debug("Fetching description(s) from " + doc.location()); - List textURLs = getDescriptionsFromPage(doc); - if (textURLs.size() > 0) { + List textURLs = getDescriptionsFromPage(doc); + if (textURLs.size() > 0) { logger.debug("Found description link(s) from " + doc.location()); - for (String textURL : textURLs) { - if (isStopped()) { - break; - } - textindex += 1; - logger.debug("Getting description from " + textURL); + for (String textURL : textURLs) { + if (isStopped()) { + break; + } + textindex += 1; + logger.debug("Getting description from " + textURL); String[] tempDesc = getDescription(textURL,doc); if (tempDesc != null) { if (Utils.getConfigBoolean("file.overwrite", false) || !(new File( @@ -116,8 +116,8 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { } } - } - } + } + } } if (isStopped() || isThisATest()) { @@ -142,7 +142,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { } public String fileNameFromURL(URL url) { String saveAs = url.toExternalForm(); - if (saveAs.substring(saveAs.length() - 1) == "/") { saveAs = saveAs.substring(0,saveAs.length() - 1) ;} + if (saveAs.substring(saveAs.length() - 1) == "/") { saveAs = saveAs.substring(0,saveAs.length() - 1) ;} saveAs = saveAs.substring(saveAs.lastIndexOf('/')+1); if (saveAs.indexOf('?') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('?')); } if (saveAs.indexOf('#') >= 0) { saveAs = saveAs.substring(0, saveAs.indexOf('#')); } 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 5bb0fae3..e61cb007 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java @@ -49,7 +49,7 @@ public class DeviantartRipper extends AbstractHTMLRipper { } @Override public boolean hasDescriptionSupport() { - return true; + return true; } @Override public URL sanitizeURL(URL url) throws MalformedURLException { @@ -132,7 +132,8 @@ public class DeviantartRipper extends AbstractHTMLRipper { continue; } script = script.substring(script.indexOf(id)); - script = script.substring(script.indexOf("},\"src\":\"") + 9, script.indexOf("\",\"type\"")); // first },"src":"url" after id + // first },"src":"url" after id + script = script.substring(script.indexOf("},\"src\":\"") + 9, script.indexOf("\",\"type\"")); return script.replace("\\/", "/"); } catch (StringIndexOutOfBoundsException e) { logger.debug("Unable to get json link from " + page.location()); @@ -156,23 +157,23 @@ public class DeviantartRipper extends AbstractHTMLRipper { } // Get full-sized image via helper methods String fullSize = null; - if (thumb.attr("data-super-full-img").contains("//orig")) { - fullSize = thumb.attr("data-super-full-img"); - } else { - String spanUrl = thumb.attr("href"); - String fullSize1 = jsonToImage(page,spanUrl.substring(spanUrl.lastIndexOf('-') + 1)); - if (fullSize1 == null || !fullSize1.contains("//orig")) { + if (thumb.attr("data-super-full-img").contains("//orig")) { + fullSize = thumb.attr("data-super-full-img"); + } else { + String spanUrl = thumb.attr("href"); + String fullSize1 = jsonToImage(page,spanUrl.substring(spanUrl.lastIndexOf('-') + 1)); + if (fullSize1 == null || !fullSize1.contains("//orig")) { fullSize = smallToFull(img.attr("src"), spanUrl); - } - if (fullSize == null && fullSize1 != null) { + } + if (fullSize == null && fullSize1 != null) { fullSize = fullSize1; } - } + } if (fullSize == null) { - if (thumb.attr("data-super-full-img") != null) { - fullSize = thumb.attr("data-super-full-img"); + if (thumb.attr("data-super-full-img") != null) { + fullSize = thumb.attr("data-super-full-img"); } else if (thumb.attr("data-super-img") != null) { - fullSize = thumb.attr("data-super-img"); + fullSize = thumb.attr("data-super-img"); } else { continue; } @@ -273,7 +274,7 @@ public class DeviantartRipper extends AbstractHTMLRipper { } return result.toString(); } - + /** * Attempts to download description for image. * Comes in handy when people put entire stories in their description. @@ -329,7 +330,7 @@ public class DeviantartRipper extends AbstractHTMLRipper { return null; } } - + /** * If largest resolution for image at 'thumb' is found, starts downloading * and returns null.