Finish gist
This commit is contained in:
@@ -6,11 +6,10 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.apache.logging.log4j.*;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
public class TeamIDMatcher {
|
||||
|
||||
@@ -19,18 +18,8 @@ public class TeamIDMatcher {
|
||||
|
||||
private static void initBiMap() {
|
||||
ids = HashBiMap.create();
|
||||
JSONArray teams = null;
|
||||
URL url = Resources.getResource("Team_ID_TLW_APIF_config.json");
|
||||
String jsonConfig = null;
|
||||
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
teams = (JSONArray) jsonParser.parse(jsonConfig);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
JSONArray teams = prov.getTeamIdMatcher();
|
||||
|
||||
for(Object team:teams) {
|
||||
int tippligaID = ((Long)((JSONObject) team).get("tippligaID")).intValue();
|
||||
|
||||
@@ -1,32 +1,36 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class APIFootballConnector {
|
||||
|
||||
private int season;
|
||||
private static APIFootballConnector conn = null;
|
||||
private final int season;
|
||||
private final String gistId;
|
||||
private HashMap<String, JSONObject> rounds = new HashMap<>();
|
||||
private HashMap<String, JSONObject> matches = new HashMap<>();
|
||||
|
||||
public APIFootballConnector(int season) {
|
||||
private APIFootballConnector(int season) {
|
||||
this.season = season;
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
this.gistId = prov.getGistID("APIFootball_" + (season + 1));
|
||||
}
|
||||
|
||||
public static APIFootballConnector getAPIFootballConnectorInstance(int season) {
|
||||
if(conn == null) {
|
||||
conn = new APIFootballConnector(season);
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
public APIFootballMatch getMatchDataByLeagueAndMatchID(int league, int id) {
|
||||
@@ -58,10 +62,14 @@ public class APIFootballConnector {
|
||||
return matchesOfMatchday;
|
||||
}
|
||||
|
||||
private ArrayList<APIFootballMatch> getMatchesFromLeagueFromFile(int id) {
|
||||
public ArrayList<APIFootballMatch> getMatchesFromLeagueFromFile(int id) {
|
||||
ArrayList<APIFootballMatch> matchesList = new ArrayList<>();
|
||||
|
||||
JSONObject matches = readFromFile("matches_league_" + id);
|
||||
String filename = "matches_league_" + id + ".json";
|
||||
if(!this.matches.containsKey(filename)) {
|
||||
this.matches.put(filename, readObjectFromFile(filename));
|
||||
}
|
||||
JSONObject matches = this.matches.get(filename);
|
||||
JSONArray matchArray = (JSONArray) (((JSONObject)matches.get("api")).get("fixtures"));
|
||||
|
||||
for(int i = 0; i < matchArray.size(); i++) {
|
||||
@@ -71,20 +79,43 @@ public class APIFootballConnector {
|
||||
return matchesList;
|
||||
}
|
||||
|
||||
public JSONObject readFromFile(String filename) {
|
||||
public JSONObject getMatchdays(int id) {
|
||||
|
||||
String filename = "rounds_" + id + ".json";
|
||||
if(!this.rounds.containsKey(filename)) {
|
||||
this.rounds.put(filename, readObjectFromFile(filename));
|
||||
}
|
||||
return this.rounds.get(filename);
|
||||
}
|
||||
|
||||
public JSONObject readObjectFromFile(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 + ".json");
|
||||
String jsonConfig = null;
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getFileFromGist(this.gistId, filename);
|
||||
|
||||
try {
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
//Read JSON file
|
||||
object = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
return object;
|
||||
}
|
||||
|
||||
public JSONArray readArrayFromFile(String filename) {
|
||||
|
||||
JSONArray object = null;
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getFileFromGist(this.gistId, filename);
|
||||
|
||||
try {
|
||||
object = (JSONArray) jsonParser.parse(jsonConfig);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class APIFootballMatchesProvider {
|
||||
|
||||
APIFootballConnector conn;
|
||||
public APIFootballMatchesProvider(int season) {
|
||||
this.conn = new APIFootballConnector(season - 1);
|
||||
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
||||
}
|
||||
|
||||
public ArrayList<APIFootballMatch> getAPIFootballMatchesFromConfig(JSONArray config) {
|
||||
|
||||
@@ -13,8 +13,6 @@ import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class APIFootballUpdater {
|
||||
@@ -24,7 +22,7 @@ public class APIFootballUpdater {
|
||||
|
||||
public APIFootballUpdater(int season) {
|
||||
this.season = season;
|
||||
this.provider = new GistProvider();
|
||||
this.provider = GistProvider.getInstance();
|
||||
}
|
||||
|
||||
public void updateFixtures(int league) throws IOException {
|
||||
@@ -41,23 +39,36 @@ public class APIFootballUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRounds(int league) throws IOException {
|
||||
String apiFootballUrl = "https://v2.api-football.com/fixtures/rounds/" + league;
|
||||
String filename = "rounds_" + league + ".json";
|
||||
String content = getRawData(apiFootballUrl);
|
||||
writeStringToGist(filename, content);
|
||||
}
|
||||
|
||||
public void updateAllRounds(String configPath) throws IOException {
|
||||
HashSet<Integer> leagues = getAllLeaguesFromLeagueConfig(configPath);
|
||||
for (Integer league : leagues) {
|
||||
updateRounds(league);
|
||||
}
|
||||
}
|
||||
|
||||
private void writeStringToGist(String filename, String content) throws UnsupportedEncodingException {
|
||||
String id = this.provider.getGistID("Matches_" + this.season);
|
||||
String id = this.provider.getGistID("APIFootball_" + this.season);
|
||||
this.provider.updateGist(id, filename, content);
|
||||
}
|
||||
|
||||
private HashSet<Integer> getAllLeaguesFromLeagueConfig(String configPath) {
|
||||
private HashSet<Integer> getAllLeaguesFromLeagueConfig(String config) {
|
||||
|
||||
HashSet<Integer> leagues = new HashSet<>();
|
||||
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
URL url = Resources.getResource(season + "\\" + configPath);
|
||||
String jsonConfig = null;
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(this.season, config);
|
||||
JSONObject configObject = null;
|
||||
try {
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
configObject = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
} catch (IOException | ParseException e) {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,18 +19,24 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
public class GistProvider {
|
||||
|
||||
private static GistProvider prov = null;
|
||||
private JSONArray gistList = null;
|
||||
public HashMap<String, String> files = new HashMap<>();
|
||||
|
||||
public GistProvider() {
|
||||
private GistProvider() {
|
||||
this.gistList = listAllGists();
|
||||
}
|
||||
|
||||
public static GistProvider getInstance() {
|
||||
if (prov == null) {
|
||||
prov = new GistProvider();
|
||||
}
|
||||
return prov;
|
||||
}
|
||||
|
||||
public JSONArray listAllGists() {
|
||||
String gistsRaw = getRawData("https://api.github.com/gists");
|
||||
return stringToJSONArray(gistsRaw);
|
||||
@@ -127,17 +133,11 @@ public class GistProvider {
|
||||
}
|
||||
|
||||
public JSONArray getTeamIdMatcher() {
|
||||
return stringToJSONArray(getFile("Team_ID_Matcher.json"));
|
||||
String id = getGistID("Team_ID_Matcher");
|
||||
return stringToJSONArray(getFileFromGist(id, "Team_ID_Matcher.json"));
|
||||
}
|
||||
|
||||
public String getFile(String filename) {
|
||||
if(!this.files.containsKey(filename)) {
|
||||
files.put(filename, getFileFromGist(filename));
|
||||
}
|
||||
return this.files.get(filename);
|
||||
}
|
||||
|
||||
private String getFileFromGist(String filename) {
|
||||
public String getFileFromGist(String id, String filename) {
|
||||
String fileurl = null;
|
||||
for (Object o : this.gistList) {
|
||||
JSONObject gist = (JSONObject) o;
|
||||
@@ -218,4 +218,14 @@ public class GistProvider {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getTippligaConfig(int season, String filename) {
|
||||
String id = getGistID("Tippliga_Config_" + season);
|
||||
return getFileFromGist(id, filename);
|
||||
}
|
||||
|
||||
public String getTippligaBaseConfig(String filename) {
|
||||
String id = getGistID("Tippliga_Config_Base");
|
||||
return getFileFromGist(id, filename);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@@ -28,13 +25,13 @@ public class TLWMatchdaysCreator {
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, configPath);
|
||||
this.matches = matchesCreator.getMatches();
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(season, configPath);
|
||||
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
URL url = Resources.getResource(season + "\\" + configPath);
|
||||
String jsonConfig = null;
|
||||
try {
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
this.configObject = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
} catch (IOException | ParseException e) {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//Read JSON file
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.jeyp91.tippliga;
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.apifootball.APIFootballConnector;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -31,21 +32,20 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.conn = new APIFootballConnector(season - 1);
|
||||
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
||||
|
||||
URL url = Resources.getResource(season + "\\" + configFileName);
|
||||
String jsonConfig = null;
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(2021, configFileName);
|
||||
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
//Read JSON file
|
||||
JSONObject config = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
|
||||
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
|
||||
this.ko = ((Long) config.get("ko")).intValue();
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
@@ -9,9 +9,6 @@ import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
||||
@@ -31,23 +28,20 @@ public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
||||
this.league = league;
|
||||
this.matchdays = matchdays;
|
||||
|
||||
URL matchPairConfigUrl = Resources.getResource("Tipper_Match_Pair_Config.json");
|
||||
URL tipperListUrl = Resources.getResource(season + "\\" + configFileName);
|
||||
URL tipperTeamConfigUrl = Resources.getResource("Tipper_Team_Config.json");
|
||||
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
|
||||
String matchPairingConfigString = Resources.toString(matchPairConfigUrl, StandardCharsets.UTF_8);
|
||||
String matchPairingConfigString = prov.getTippligaBaseConfig("Tipper_Match_Pair_Config.json");
|
||||
this.matchPairingConfig = (JSONArray) jsonParser.parse(matchPairingConfigString);
|
||||
|
||||
String tipperListString = Resources.toString(tipperListUrl, StandardCharsets.UTF_8);
|
||||
String tipperListString = prov.getTippligaConfig(season, configFileName);
|
||||
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
||||
|
||||
String tipperTeamConfigString = Resources.toString(tipperTeamConfigUrl, StandardCharsets.UTF_8);
|
||||
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
||||
this.tipperTeamConfig = (JSONArray) jsonParser.parse(tipperTeamConfigString);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
@@ -8,9 +8,6 @@ import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
||||
@@ -30,21 +27,21 @@ public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
||||
this.league = league;
|
||||
this.matchdays = matchdays;
|
||||
|
||||
URL tipperListUrl = Resources.getResource(season + "\\" + configFileName);
|
||||
URL tipperTeamConfigUrl = Resources.getResource("Tipper_Team_Config.json");
|
||||
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
|
||||
this.TLWMatches = new ArrayList<>();
|
||||
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
|
||||
String tipperListString = Resources.toString(tipperListUrl, StandardCharsets.UTF_8);
|
||||
String tipperListString = prov.getTippligaConfig(season, configFileName);
|
||||
this.tipperList = (JSONObject) jsonParser.parse(tipperListString);
|
||||
|
||||
String tipperTeamConfigString = Resources.toString(tipperTeamConfigUrl, StandardCharsets.UTF_8);
|
||||
String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json");
|
||||
this.tipperTeamConfig = (JSONArray) jsonParser.parse(tipperTeamConfigString);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import de.jeyp91.gists.GistProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -25,18 +21,17 @@ public class TLWMatchesManagerBase {
|
||||
|
||||
protected void initConfigParamsFromFile(String configFileName) {
|
||||
|
||||
URL url = Resources.getResource(season + File.separator + configFileName);
|
||||
String jsonConfig = null;
|
||||
GistProvider prov = GistProvider.getInstance();
|
||||
String jsonConfig = prov.getTippligaConfig(season, configFileName);
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
//Read JSON file
|
||||
JSONObject config = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
|
||||
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
|
||||
this.ko = ((Long) config.get("ko")).intValue();
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import com.google.api.client.util.DateTime;
|
||||
import de.jeyp91.TeamIDMatcher;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.apifootball.APIFootballMatchesProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -133,7 +136,13 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
{
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatches);
|
||||
tlwMatch.setMatchDateTime(apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19));
|
||||
OffsetDateTime offsetDateTime = OffsetDateTime.parse(apiFootballMatch.getMatchDateTime());
|
||||
ZonedDateTime now = ZonedDateTime.now();
|
||||
ZoneOffset offsetNow = now.getOffset();
|
||||
OffsetDateTime fixedDatetime = offsetDateTime.withOffsetSameInstant(offsetNow);
|
||||
String newMatchTime = fixedDatetime.toString();
|
||||
|
||||
tlwMatch.setMatchDateTime(newMatchTime.replace("T", " ").substring(0, 16) + ":00");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user