diff --git a/.vscode/launch.json b/.vscode/launch.json index aebe6f6..dd8fca6 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -34,7 +34,15 @@ "request": "launch", "mainClass": "de.jeyp91.App", "envFile": "${workspaceFolder}/.env", - "args": " --mode MatchesResultsUpdater --season 2025 --league 2 --configFile Tippliga" + "args": " --mode MatchesResultsUpdater --season 2025 --league 1 --configFile Tippliga" + }, + { + "type": "java", + "name": "MatchesListGistUpdater", + "request": "launch", + "mainClass": "de.jeyp91.App", + "envFile": "${workspaceFolder}/.env", + "args": " --mode MatchesListGistUpdater --season 2025 --league 1 --configFile Tippliga" } ] } \ No newline at end of file diff --git a/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java b/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java index 1ea4cfc..01ad7a5 100644 --- a/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java +++ b/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java @@ -1,11 +1,16 @@ package de.jeyp91.tippligaforum; -import com.google.gson.*; -import de.jeyp91.S3Provider; -import de.jeyp91.apifootball.APIFootballMatch; import org.json.simple.JSONArray; import org.json.simple.JSONObject; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; + +import de.jeyp91.S3Provider; +import de.jeyp91.apifootball.APIFootballMatch; + public class MatchesListCreator { private final JSONObject mainObject = new JSONObject(); @@ -19,8 +24,7 @@ public class MatchesListCreator { this.league = league; S3Provider prov = new S3Provider(); JSONObject leagueConfig = prov.getFixturesJSONFromS3(season, league); - JSONObject api = (JSONObject) leagueConfig.get("api"); - JSONArray matchesAPIFootball = (JSONArray) api.get("fixtures"); + JSONArray matchesAPIFootball = (JSONArray) leagueConfig.get("response"); JSONObject firstMatchAPIFootball = (JSONObject) matchesAPIFootball.get(0); JSONObject leagueObject = (JSONObject) firstMatchAPIFootball.get("league"); @@ -44,16 +48,20 @@ public class MatchesListCreator { JSONObject matchAPIFootball = (JSONObject) matchAPIFootballObject; JSONObject match = new JSONObject(); - Long leagueId = (Long) matchAPIFootball.get("league_id"); - String matchdayString = matchAPIFootball.get("round").toString(); + JSONObject leagueObject = (JSONObject) matchAPIFootball.get("league"); + Long leagueId = (Long) leagueObject.get("id"); + String matchdayString = leagueObject.get("round").toString(); int matchday = APIFootballMatch.getMatchdayFromRoundString(this.season, matchdayString, leagueId.intValue()); - String matchtime = matchAPIFootball.get("event_date").toString().replace("T", " ").substring(0, 16); - Long fixtureId = (Long) matchAPIFootball.get("fixture_id"); - JSONObject teamHome = (JSONObject) matchAPIFootball.get("homeTeam"); - String teamNameHome = teamHome.get("team_name").toString(); - JSONObject teamGuest = (JSONObject) matchAPIFootball.get("awayTeam"); - String teamNameGuest = teamGuest.get("team_name").toString(); + JSONObject fixtureObject = (JSONObject) matchAPIFootball.get("fixture"); + String matchtime = fixtureObject.get("date").toString().replace("T", " ").substring(0, 16); + Long fixtureId = (Long) fixtureObject.get("id"); + + JSONObject teamsObject = (JSONObject) matchAPIFootball.get("teams"); + JSONObject teamHome = (JSONObject) teamsObject.get("home"); + String teamNameHome = teamHome.get("name").toString(); + JSONObject teamGuest = (JSONObject) teamsObject.get("away"); + String teamNameGuest = teamGuest.get("name").toString(); match.put("match", teamNameHome + " - " + teamNameGuest); match.put("matchday", matchday); diff --git a/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java index b7c33e2..2be21d4 100644 --- a/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java +++ b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java @@ -1,14 +1,14 @@ package de.jeyp91.tippligaforum; -import de.jeyp91.App; -import de.jeyp91.apifootball.APIFootballUpdater; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import de.jeyp91.apifootball.APIFootballUpdater; + public class MatchesListForumUpdater { private HashSet leagues; private static final Logger logger = LoggerFactory.getLogger(MatchesListForumUpdater.class); diff --git a/src/main/resources/Tippliga/Ligen_v3.json b/src/main/resources/Tippliga/Ligen_v3.json index 4ef55bf..311ac45 100644 --- a/src/main/resources/Tippliga/Ligen_v3.json +++ b/src/main/resources/Tippliga/Ligen_v3.json @@ -93,5 +93,15 @@ "country": "World", "name": "UEFA Super Cup", "league_id": 531 + }, + { + "country": "World", + "name": "World Cup", + "league_id": 1 + }, + { + "country": "World", + "name": "Euro Championship", + "league_id": 4 } ] \ No newline at end of file