Fix api rate limit
This commit is contained in:
@@ -25,16 +25,15 @@ public class APIFootballUpdater {
|
||||
|
||||
public void updateFixtures(int league) {
|
||||
String apiFootballUrl = "https://v2.api-football.com/fixtures/league/" + league + "?timezone=Europe/Berlin";
|
||||
S3Provider prov = new S3Provider();
|
||||
try {
|
||||
String content = getRawData(apiFootballUrl);
|
||||
S3Provider prov = new S3Provider();
|
||||
prov.writeFixturesToS3(league, content);
|
||||
} catch (Exception e) {
|
||||
if(e.getMessage().endsWith("did not have any results with status: 'Too many requests. Your rate limit is 10 requests per minute.'")) {
|
||||
if(e.getMessage().toLowerCase().contains("rate limit'")) {
|
||||
try {
|
||||
Thread.sleep(1000 * 60);
|
||||
String content = getRawData(apiFootballUrl);
|
||||
S3Provider prov = new S3Provider();
|
||||
prov.writeFixturesToS3(league, content);
|
||||
} catch (InterruptedException interruptedException) {
|
||||
interruptedException.printStackTrace();
|
||||
@@ -51,6 +50,11 @@ public class APIFootballUpdater {
|
||||
HashSet<Integer> leagues = getLeagues(season);
|
||||
for (Integer league : leagues) {
|
||||
updateFixtures(league);
|
||||
try {
|
||||
Thread.sleep(1000*6);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,21 +62,25 @@ public class APIFootballUpdater {
|
||||
HashSet<Integer> leagues = getLeagues(season);
|
||||
for (Integer league : leagues) {
|
||||
updateRounds(league);
|
||||
try {
|
||||
Thread.sleep(1000*6);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRounds(int league) {
|
||||
String apiFootballUrl = "https://v2.api-football.com/fixtures/rounds/" + league;
|
||||
S3Provider prov = new S3Provider();
|
||||
try {
|
||||
String content = getRawData(apiFootballUrl);
|
||||
S3Provider prov = new S3Provider();
|
||||
prov.writeRoundsToS3(league, content);
|
||||
} catch (Exception e) {
|
||||
if(e.getMessage().endsWith("did not have any results with status: 'Too many requests. Your rate limit is 10 requests per minute.'")) {
|
||||
if(e.getMessage().toLowerCase().contains("rate limit'")) {
|
||||
try {
|
||||
Thread.sleep(1000 * 60);
|
||||
String content = getRawData(apiFootballUrl);
|
||||
S3Provider prov = new S3Provider();
|
||||
prov.writeRoundsToS3(league, content);
|
||||
} catch (InterruptedException interruptedException) {
|
||||
interruptedException.printStackTrace();
|
||||
@@ -117,7 +125,7 @@ public class APIFootballUpdater {
|
||||
while (true) {
|
||||
try {
|
||||
line = rd.readLine();
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user