Moved Steam API key to separate class
(and yes, I changed my API key)
This commit is contained in:
parent
3e203f43b3
commit
c65a800515
1
.gitignore
vendored
1
.gitignore
vendored
@ -159,3 +159,4 @@ $RECYCLE.BIN/
|
||||
/steamapps.json
|
||||
/test.json
|
||||
/steam_api.md5
|
||||
/src/main/java/util/env/Default.java
|
||||
|
@ -11,6 +11,7 @@ import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
import pojo.App;
|
||||
import pojo.SteamAppsList;
|
||||
import util.env.MainEnv;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
@ -24,11 +25,22 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class SteamAppsListCache {
|
||||
|
||||
private static final String KEY = "E427256C579D3CDF1D504810E8F5B948";
|
||||
private SteamAppsList list = new SteamAppsList();
|
||||
private File cacheFile = new File("steamapps.json");
|
||||
private MainEnv env;
|
||||
//private String key;
|
||||
|
||||
public SteamAppsListCache() {
|
||||
try {
|
||||
Class envDefault = Class.forName("util.env.Default");
|
||||
env = (MainEnv) envDefault.newInstance();
|
||||
//System.out.println(env.getKey());
|
||||
} catch (ClassNotFoundException e) {
|
||||
env = new MainEnv();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
// Only thrown by newInstance()
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean fileFound = true;
|
||||
try {
|
||||
getListFromFile();
|
||||
@ -85,7 +97,7 @@ public class SteamAppsListCache {
|
||||
private List<App> getApps() {
|
||||
HttpResponse<String> httpResponse =
|
||||
Unirest.get("https://api.steampowered.com/IStoreService/GetAppList/v1/" +
|
||||
"?key=" + KEY + "&include_games=1&max_results=50000").asString();
|
||||
"?key=" + env.getKey() + "&include_games=1&max_results=50000").asString();
|
||||
return new Gson()
|
||||
.fromJson(httpResponse.getBody(), App.Rezponze.Download.class)
|
||||
.getResponse().getApps();
|
||||
|
9
src/main/java/util/env/MainEnv.java
vendored
Normal file
9
src/main/java/util/env/MainEnv.java
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
package util.env;
|
||||
|
||||
public class MainEnv {
|
||||
String key = "";
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user