Rework rounds parser to support wrongly sorted league rounds
This commit is contained in:
@@ -41,6 +41,9 @@ 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;
|
||||||
|
if (round.startsWith("Regular_Season_-_")) {
|
||||||
|
matchday = Integer.parseInt(round.replace("Regular_Season_-_", ""));
|
||||||
|
} else {
|
||||||
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(season);
|
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(season);
|
||||||
JSONObject roundsObject = con.getMatchdays(leagueId);
|
JSONObject roundsObject = con.getMatchdays(leagueId);
|
||||||
JSONArray roundsArray = (JSONArray)(((JSONObject) roundsObject.get("api")).get("fixtures"));
|
JSONArray roundsArray = (JSONArray)(((JSONObject) roundsObject.get("api")).get("fixtures"));
|
||||||
@@ -50,6 +53,7 @@ public class APIFootballMatch extends BaseMatch {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return matchday;
|
return matchday;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user