Finish gist
This commit is contained in:
@@ -2,6 +2,7 @@ package de.jeyp91.apifootball;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.BaseMatch;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -43,7 +44,8 @@ public class APIFootballMatch extends BaseMatch {
|
||||
private int getMatchdayFromRoundString(String round, int leagueId) {
|
||||
round = round.replace(" ", "_");
|
||||
Integer matchday = null;
|
||||
JSONObject roundsObject = readFromFile("rounds_" + leagueId + ".json");
|
||||
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(this.season);
|
||||
JSONObject roundsObject = con.getMatchdays(leagueId);
|
||||
JSONArray roundsArray = (JSONArray)(((JSONObject) roundsObject.get("api")).get("fixtures"));
|
||||
for (int i = 0; i < roundsArray.size(); i++) {
|
||||
if(roundsArray.get(i).toString().equals(round)) {
|
||||
@@ -54,26 +56,6 @@ public class APIFootballMatch extends BaseMatch {
|
||||
return matchday;
|
||||
}
|
||||
|
||||
private JSONObject readFromFile(String filename) {
|
||||
|
||||
JSONObject object = null;
|
||||
//JSON parser object to parse read file
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
URL url = Resources.getResource((this.season + 1) + "\\API-Football\\" + filename);
|
||||
String jsonConfig = null;
|
||||
|
||||
try {
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
//Read JSON file
|
||||
object = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
private Integer getNumberOrNull(Object object) {
|
||||
return object != null ? Integer.parseInt(object.toString()) : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user