From e89b27dc1485fb43ea19a42eb4a0ad8c78dc28a5 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 2 Dec 2017 04:49:53 -0500 Subject: [PATCH 1/3] Added hasASAPRipping(), which if returns true allows a ripper to not return anything from getURLsFromPage() --- .../ripme/ripper/AbstractHTMLRipper.java | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java index 3b7496a0..80bdcb34 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java @@ -53,6 +53,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { protected boolean hasDescriptionSupport() { return false; } + public boolean hasASAPRipping() {return false;} protected String[] getDescription(String url, Document page) throws IOException { throw new IOException("getDescription not implemented"); // Do I do this or make an abstract function? } @@ -68,24 +69,27 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { Document doc = getFirstPage(); while (doc != null) { - List imageURLs = getURLsFromPage(doc); - // Remove all but 1 image - if (isThisATest()) { - while (imageURLs.size() > 1) { - imageURLs.remove(1); + List imageURLs; + if (!hasASAPRipping()) { + imageURLs = getURLsFromPage(doc); + // Remove all but 1 image + if (isThisATest()) { + while (imageURLs.size() > 1) { + imageURLs.remove(1); + } } - } - if (imageURLs.size() == 0) { - throw new IOException("No images found at " + doc.location()); - } + 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); - downloadURL(new URL(imageURL), index); - if (isStopped()) { - break; + for (String imageURL : imageURLs) { + index += 1; + logger.debug("Found image url #" + index + ": " + imageURL); + downloadURL(new URL(imageURL), index); + if (isStopped()) { + break; + } } } if (hasDescriptionSupport() && Utils.getConfigBoolean("descriptions.save", false)) { From 761f1e29879c3d6a5a1313a3387874a75062c057 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 2 Dec 2017 05:09:22 -0500 Subject: [PATCH 2/3] Fixed bug that caused no images to be downloaded --- .../java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java index 80bdcb34..4646df31 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java @@ -53,7 +53,7 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { protected boolean hasDescriptionSupport() { return false; } - public boolean hasASAPRipping() {return false;} + public boolean hasASAPRipping() { return false; } protected String[] getDescription(String url, Document page) throws IOException { throw new IOException("getDescription not implemented"); // Do I do this or make an abstract function? } @@ -69,9 +69,8 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { Document doc = getFirstPage(); while (doc != null) { - List imageURLs; + List imageURLs = getURLsFromPage(doc); if (!hasASAPRipping()) { - imageURLs = getURLsFromPage(doc); // Remove all but 1 image if (isThisATest()) { while (imageURLs.size() > 1) { From 61169352cbfecf92cb37b3450e9847b274e0764b Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sat, 2 Dec 2017 19:20:09 -0500 Subject: [PATCH 3/3] Moved hasASAPRipping() from AbstractHTMLRipper to AbstractRipper --- src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java | 1 - src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java index 4646df31..3e74912a 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractHTMLRipper.java @@ -53,7 +53,6 @@ public abstract class AbstractHTMLRipper extends AlbumRipper { protected boolean hasDescriptionSupport() { return false; } - public boolean hasASAPRipping() { return false; } protected String[] getDescription(String url, Document page) throws IOException { throw new IOException("getDescription not implemented"); // Do I do this or make an abstract function? } diff --git a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java index a852e177..090b4e42 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AbstractRipper.java @@ -43,6 +43,7 @@ public abstract class AbstractRipper public abstract void rip() throws IOException; public abstract String getHost(); public abstract String getGID(URL url) throws MalformedURLException; + public boolean hasASAPRipping() { return false; } private boolean shouldStop = false; private boolean thisIsATest = false;