Reddit ripper now respects history.end_rip_after_already_seen

This commit is contained in:
cyian-1756 2018-06-22 17:04:28 -04:00
parent 0918ab4616
commit f5bdada31b

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import com.rarchives.ripme.ui.RipStatusMessage;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.JSONTokener; import org.json.JSONTokener;
@ -39,6 +40,10 @@ public class RedditRipper extends AlbumRipper {
private long lastRequestTime = 0; private long lastRequestTime = 0;
private Boolean shouldAddURL() {
return (alreadyDownloadedUrls >= Utils.getConfigInteger("history.end_rip_after_already_seen", 1000000000) && !isThisATest());
}
@Override @Override
public boolean canRip(URL url) { public boolean canRip(URL url) {
return url.getHost().endsWith(DOMAIN); return url.getHost().endsWith(DOMAIN);
@ -65,6 +70,10 @@ public class RedditRipper extends AlbumRipper {
public void rip() throws IOException { public void rip() throws IOException {
URL jsonURL = getJsonURL(this.url); URL jsonURL = getJsonURL(this.url);
while (true) { while (true) {
if (shouldAddURL()) {
sendUpdate(RipStatusMessage.STATUS.DOWNLOAD_COMPLETE_HISTORY, "Already seen the last " + alreadyDownloadedUrls + " images ending rip");
break;
}
jsonURL = getAndParseAndReturnNext(jsonURL); jsonURL = getAndParseAndReturnNext(jsonURL);
if (jsonURL == null || isThisATest() || isStopped()) { if (jsonURL == null || isThisATest() || isStopped()) {
break; break;