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) {
|
||||
round = round.replace(" ", "_");
|
||||
Integer matchday = null;
|
||||
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(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)) {
|
||||
matchday = i + 1;
|
||||
break;
|
||||
if (round.startsWith("Regular_Season_-_")) {
|
||||
matchday = Integer.parseInt(round.replace("Regular_Season_-_", ""));
|
||||
} else {
|
||||
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(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)) {
|
||||
matchday = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchday;
|
||||
|
||||
Reference in New Issue
Block a user