Small fixes and workarounds

This commit is contained in:
2025-01-28 19:56:18 +01:00
parent 38fba7b906
commit 32bc791bd0
5 changed files with 38 additions and 16 deletions

View File

@@ -8,11 +8,11 @@ import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.jeyp91.ResourceProvider;
import de.jeyp91.S3Provider;
@@ -20,7 +20,7 @@ import de.jeyp91.S3Provider;
public class APIFootballUpdater {
private static final Logger logger = LoggerFactory.getLogger(APIFootballUpdater.class);
private static final String baseurl = "https://v3.football.api-sports.io/";
private static final String BASE_URL = "https://v3.football.api-sports.io/";
public APIFootballUpdater() {
@@ -99,7 +99,7 @@ public class APIFootballUpdater {
public String getRawData(String requestPath, int season, int league) throws Exception {
HttpClient client = HttpClientBuilder.create().build();
String requestUrl = baseurl + requestPath + "?season=" + (season-1) + "&league=" + league + "&timezone=Europe/Berlin";
String requestUrl = BASE_URL + requestPath + "?season=" + (season-1) + "&league=" + league + "&timezone=Europe/Berlin";
HttpGet request = new HttpGet(requestUrl);
// add request header
@@ -136,8 +136,7 @@ public class APIFootballUpdater {
String errorMessage = resultObject.get("errors").toString();
throw new Exception(requestUrl + " returned error: '" + errorMessage + "'");
} else if (results == 0) {
String statusMessage = ((JSONObject) resultObject.get("api")).get("status").toString();
throw new Exception(requestUrl + " did not have any results with status: '" + statusMessage + "'");
throw new Exception(requestUrl + " did not have any results.");
}
}