Rework rounds parser to support wrongly sorted league rounds
This commit is contained in:
@@ -41,13 +41,17 @@ public class APIFootballMatch extends BaseMatch {
|
|||||||
public static int getMatchdayFromRoundString(int season, String round, int leagueId) {
|
public static int getMatchdayFromRoundString(int season, String round, int leagueId) {
|
||||||
round = round.replace(" ", "_");
|
round = round.replace(" ", "_");
|
||||||
Integer matchday = null;
|
Integer matchday = null;
|
||||||
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(season);
|
if (round.startsWith("Regular_Season_-_")) {
|
||||||
JSONObject roundsObject = con.getMatchdays(leagueId);
|
matchday = Integer.parseInt(round.replace("Regular_Season_-_", ""));
|
||||||
JSONArray roundsArray = (JSONArray)(((JSONObject) roundsObject.get("api")).get("fixtures"));
|
} else {
|
||||||
for (int i = 0; i < roundsArray.size(); i++) {
|
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(season);
|
||||||
if(roundsArray.get(i).toString().equals(round)) {
|
JSONObject roundsObject = con.getMatchdays(leagueId);
|
||||||
matchday = i + 1;
|
JSONArray roundsArray = (JSONArray)(((JSONObject) roundsObject.get("api")).get("fixtures"));
|
||||||
break;
|
for (int i = 0; i < roundsArray.size(); i++) {
|
||||||
|
if(roundsArray.get(i).toString().equals(round)) {
|
||||||
|
matchday = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return matchday;
|
return matchday;
|
||||||
|
|||||||
Reference in New Issue
Block a user