From 535efb4d880494b02313d4d9fe66680fc4d2c8a6 Mon Sep 17 00:00:00 2001 From: 4pr0n Date: Wed, 30 Apr 2014 20:13:44 -0700 Subject: [PATCH] 1.0.33 - Allow duplicate URLs on the imgur ripper --- pom.xml | 2 +- .../java/com/rarchives/ripme/ripper/AlbumRipper.java | 11 ++++++++--- .../rarchives/ripme/ripper/rippers/ImgurRipper.java | 10 ++++++++++ src/main/java/com/rarchives/ripme/ui/UpdateUtils.java | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 533c3f5b..38290a05 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.rarchives.ripme ripme jar - 1.0.32 + 1.0.33 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 8161d7c0..71488623 100644 --- a/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/AlbumRipper.java @@ -28,10 +28,15 @@ public abstract class AlbumRipper extends AbstractRipper { public abstract String getHost(); public abstract String getGID(URL url) throws MalformedURLException; + public boolean allowDuplicates() { + return false; + } + public void addURLToDownload(URL url, File saveAs, String referrer, Map cookies) { - if (itemsPending.containsKey(url) - || itemsCompleted.containsKey(url) - || itemsErrored.containsKey(url)) { + if (!allowDuplicates() + && ( itemsPending.containsKey(url) + || itemsCompleted.containsKey(url) + || itemsErrored.containsKey(url) )) { // Item is already downloaded/downloading, skip it. logger.info("[!] Skipping " + url + " -- already attempted: " + Utils.removeCWD(saveAs)); return; diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java index d2d39916..d5a8f4bd 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/ImgurRipper.java @@ -45,6 +45,15 @@ public class ImgurRipper extends AlbumRipper { SLEEP_BETWEEN_ALBUMS = 1; } + /** + * Imgur ripper does not return the same URL except when ripping + * many albums at once (USER). In this case, we want duplicates. + */ + @Override + public boolean allowDuplicates() { + return true; + } + public boolean canRip(URL url) { if (!url.getHost().endsWith(DOMAIN)) { return false; @@ -129,6 +138,7 @@ public class ImgurRipper extends AlbumRipper { logger.info(" Retrieving " + url.toExternalForm()); Document doc = Jsoup.connect(url.toExternalForm()) .userAgent(USER_AGENT) + .timeout(10 * 1000) .maxBodySize(0) .get(); diff --git a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java index 744b64d5..ee57a8f5 100644 --- a/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java +++ b/src/main/java/com/rarchives/ripme/ui/UpdateUtils.java @@ -19,7 +19,7 @@ import org.jsoup.nodes.Document; public class UpdateUtils { private static final Logger logger = Logger.getLogger(UpdateUtils.class); - private static final String DEFAULT_VERSION = "1.0.32"; + private static final String DEFAULT_VERSION = "1.0.33"; 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";