From f5bdada31b6047c0f5aa4db5431d0fe5a9f3e6e4 Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Fri, 22 Jun 2018 17:04:28 -0400 Subject: [PATCH] Reddit ripper now respects history.end_rip_after_already_seen --- .../com/rarchives/ripme/ripper/rippers/RedditRipper.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java index 5a967068..08229d72 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/RedditRipper.java @@ -8,6 +8,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import com.rarchives.ripme.ui.RipStatusMessage; import org.json.JSONArray; import org.json.JSONObject; import org.json.JSONTokener; @@ -39,6 +40,10 @@ public class RedditRipper extends AlbumRipper { private long lastRequestTime = 0; + private Boolean shouldAddURL() { + return (alreadyDownloadedUrls >= Utils.getConfigInteger("history.end_rip_after_already_seen", 1000000000) && !isThisATest()); + } + @Override public boolean canRip(URL url) { return url.getHost().endsWith(DOMAIN); @@ -65,6 +70,10 @@ public class RedditRipper extends AlbumRipper { public void rip() throws IOException { URL jsonURL = getJsonURL(this.url); while (true) { + if (shouldAddURL()) { + sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_COMPLETE_HISTORY, "Already seen the last " + alreadyDownloadedUrls + " images ending rip"); + break; + } jsonURL = getAndParseAndReturnNext(jsonURL); if (jsonURL == null || isThisATest() || isStopped()) { break;