Tumblr ripper now tells the user if it hits the rate limit
This commit is contained in:
parent
8b96bc01e8
commit
44ab7fd29a
@ -95,6 +95,7 @@ public class TumblrRipper extends AlbumRipper {
|
|||||||
@Override
|
@Override
|
||||||
public void rip() throws IOException {
|
public void rip() throws IOException {
|
||||||
String[] mediaTypes;
|
String[] mediaTypes;
|
||||||
|
boolean exceededRateLimit = false;
|
||||||
if (albumType == ALBUM_TYPE.POST) {
|
if (albumType == ALBUM_TYPE.POST) {
|
||||||
mediaTypes = new String[] { "post" };
|
mediaTypes = new String[] { "post" };
|
||||||
} else {
|
} else {
|
||||||
@ -105,12 +106,21 @@ public class TumblrRipper extends AlbumRipper {
|
|||||||
if (isStopped()) {
|
if (isStopped()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exceededRateLimit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
offset = 0;
|
offset = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (isStopped()) {
|
if (isStopped()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (exceededRateLimit) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String apiURL = getTumblrApiURL(mediaType, offset);
|
String apiURL = getTumblrApiURL(mediaType, offset);
|
||||||
logger.info("Retrieving " + apiURL);
|
logger.info("Retrieving " + apiURL);
|
||||||
sendUpdate(STATUS.LOADING_RESOURCE, apiURL);
|
sendUpdate(STATUS.LOADING_RESOURCE, apiURL);
|
||||||
@ -126,6 +136,11 @@ public class TumblrRipper extends AlbumRipper {
|
|||||||
HttpStatusException status = (HttpStatusException)cause;
|
HttpStatusException status = (HttpStatusException)cause;
|
||||||
if (status.getStatusCode() == HttpURLConnection.HTTP_UNAUTHORIZED && !useDefaultApiKey) {
|
if (status.getStatusCode() == HttpURLConnection.HTTP_UNAUTHORIZED && !useDefaultApiKey) {
|
||||||
retry = true;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user