From 44ab7fd29a5307d39ded737b3f9b3a5c2603155d Mon Sep 17 00:00:00 2001 From: cyian-1756 Date: Sun, 17 Dec 2017 00:51:42 -0500 Subject: [PATCH] Tumblr ripper now tells the user if it hits the rate limit --- .../ripme/ripper/rippers/TumblrRipper.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java index 5a22b834..018cd9e4 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/TumblrRipper.java @@ -95,6 +95,7 @@ public class TumblrRipper extends AlbumRipper { @Override public void rip() throws IOException { String[] mediaTypes; + boolean exceededRateLimit = false; if (albumType == ALBUM_TYPE.POST) { mediaTypes = new String[] { "post" }; } else { @@ -105,12 +106,21 @@ public class TumblrRipper extends AlbumRipper { if (isStopped()) { break; } + + if (exceededRateLimit) { + break; + } offset = 0; while (true) { if (isStopped()) { break; } + if (exceededRateLimit) { + break; + } + + String apiURL = getTumblrApiURL(mediaType, offset); logger.info("Retrieving " + apiURL); sendUpdate(STATUS.LOADING_RESOURCE, apiURL); @@ -126,6 +136,11 @@ public class TumblrRipper extends AlbumRipper { HttpStatusException status = (HttpStatusException)cause; if (status.getStatusCode() == HttpURLConnection.HTTP_UNAUTHORIZED && !useDefaultApiKey) { retry = true; + } else if (status.getStatusCode() == 429) { + logger.error("Tumblr rate limit has been exceeded"); + sendUpdate(STATUS.DOWNLOAD_ERRORED,"Tumblr rate limit has been exceeded"); + exceededRateLimit = true; + break; } } }