From 14c2d8a31791dd72254aeaf70dc0f34a0afb0e36 Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Sun, 11 May 2014 10:07:58 -0700 Subject: [PATCH] 1.0.38 - Rips large imagefap galleries Closes #25 --- pom.xml | 2 +- .../rarchives/ripme/ripper/AlbumRipper.java | 1 + .../ripme/ripper/rippers/ImagefapRipper.java | 46 +++++++++++++++---- .../com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 9c72e38e..3a027822 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.37 + 1.0.38 ripme http://rip.rarchives.com diff --git a/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java b/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java index 2cddc1ce..20378c00 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java @@ -204,6 +204,7 @@ public abstract class AlbumRipper extends AbstractRipper { } connection.ignoreContentType(ignoreContentType); + connection.maxBodySize(0); Response response = null; int retries = Utils.getConfigInteger("download.retries", 1);; while (retries >= 0) { diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java index 3f781da9..d003ab52 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImagefapRipper.java @@ -12,6 +12,7 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import com.rarchives.ripme.ripper.AlbumRipper; +import com.rarchives.ripme.ui.RipStatusMessage.STATUS; public class ImagefapRipper extends AlbumRipper { @@ -85,20 +86,47 @@ public class ImagefapRipper extends AlbumRipper { @Override public void rip() throws IOException { int index = 0; + sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm()); logger.info(" Retrieving " + this.url.toExternalForm()); if (albumDoc == null) { albumDoc = Jsoup.connect(this.url.toExternalForm()).get(); } - for (Element thumb : albumDoc.select("#gallery img")) { - if (!thumb.hasAttr("src") || !thumb.hasAttr("width")) { - continue; + while (true) { + if (isStopped()) { + break; + } + for (Element thumb : albumDoc.select("#gallery img")) { + if (!thumb.hasAttr("src") || !thumb.hasAttr("width")) { + continue; + } + String image = thumb.attr("src"); + image = image.replaceAll( + "http://x.*.fap.to/images/thumb/", + "http://fap.to/images/full/"); + index += 1; + addURLToDownload(new URL(image), String.format("%03d_", index)); + } + String nextURL = null; + for (Element a : albumDoc.select("a.link3")) { + if (a.text().contains("next")) { + nextURL = a.attr("href"); + nextURL = "http://imagefap.com/gallery.php" + nextURL; + break; + } + } + if (nextURL == null) { + break; + } + else { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + logger.error("Interrupted while waiting to load next page", e); + throw new IOException(e); + } + sendUpdate(STATUS.LOADING_RESOURCE, this.url.toExternalForm()); + albumDoc = Jsoup.connect(nextURL).get(); } - String image = thumb.attr("src"); - image = image.replaceAll( - "http://x.*.fap.to/images/thumb/", - "http://fap.to/images/full/"); - index += 1; - addURLToDownload(new URL(image), String.format("%03d_", index)); } waitForThreads(); } diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index c0374a5e..35b8e35d 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -21,7 +21,7 @@ import com.rarchives.ripme.utils.Utils; public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.0.37"; + private static final String DEFAULT_VERSION = "1.0.38"; private static final String updateJsonURL = "http://rarchives.com/ripme.json"; private static final String updateJarURL = "http://rarchives.com/ripme.jar"; private static final String mainFileName = "ripme.jar";