Add wait and retry for API Football minute rate limit
This commit is contained in:
@@ -2,7 +2,6 @@ package de.jeyp91.apifootball;
|
||||
|
||||
import de.jeyp91.ResourceProvider;
|
||||
import de.jeyp91.S3Provider;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
@@ -31,7 +30,20 @@ public class APIFootballUpdater {
|
||||
S3Provider prov = new S3Provider();
|
||||
prov.writeFixturesToS3(league, content);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
if(e.getMessage().endsWith("did not have any results with status: 'Too many requests. Your rate limit is 10 requests per minute.")) {
|
||||
try {
|
||||
Thread.sleep(1000 * 60);
|
||||
String content = getRawData(apiFootballUrl);
|
||||
S3Provider prov = new S3Provider();
|
||||
prov.writeFixturesToS3(league, content);
|
||||
} catch (InterruptedException interruptedException) {
|
||||
interruptedException.printStackTrace();
|
||||
} catch (Exception exception) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user