Finish gist
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user