eh whatevs sry future me
This commit is contained in:
parent
1fdf90da8a
commit
272b1d0833
@ -34,7 +34,6 @@ import javafx.scene.control.*;
|
|||||||
import javafx.stage.*;
|
import javafx.stage.*;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
import org.jsoup.HttpStatusException;
|
|
||||||
import xyz.jeddunk.autocreamapi.pojo.App;
|
import xyz.jeddunk.autocreamapi.pojo.App;
|
||||||
import xyz.jeddunk.autocreamapi.util.CreamApiConfig;
|
import xyz.jeddunk.autocreamapi.util.CreamApiConfig;
|
||||||
import xyz.jeddunk.autocreamapi.util.CreamApiDllHandler;
|
import xyz.jeddunk.autocreamapi.util.CreamApiDllHandler;
|
||||||
@ -303,7 +302,8 @@ public class Controller implements Initializable {
|
|||||||
appId_textfield.setText(String.valueOf(game.getAppId()));
|
appId_textfield.setText(String.valueOf(game.getAppId()));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("searchResultWindow.fxml"));
|
URL resource = ClassLoader.getSystemResource("searchResultWindow.fxml");
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader(resource);
|
||||||
Parent root1 = fxmlLoader.load();
|
Parent root1 = fxmlLoader.load();
|
||||||
|
|
||||||
SearchResultWindowController c = fxmlLoader.getController();
|
SearchResultWindowController c = fxmlLoader.getController();
|
||||||
@ -338,26 +338,10 @@ public class Controller implements Initializable {
|
|||||||
return new Task<Void>() {
|
return new Task<Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void call() {
|
protected Void call() {
|
||||||
try {
|
Map<Integer, String> collect = cache.getDlcMap(appId_textfield.getText());
|
||||||
Map<Number, String> collect = cache.getDlcMap(appId_textfield.getText());
|
StringBuilder sb = new StringBuilder();
|
||||||
StringBuilder sb = new StringBuilder();
|
collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n"));
|
||||||
collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n"));
|
dlc_textarea.setText(sb.toString());
|
||||||
dlc_textarea.setText(sb.toString());
|
|
||||||
} catch (HttpStatusException e) {
|
|
||||||
if (e.getStatusCode() == 404) {
|
|
||||||
System.err.println("App ID empty or not found! (HTTP Status Code: 404)");
|
|
||||||
System.err.println(e.getUrl());
|
|
||||||
} else {
|
|
||||||
System.err.printf("Error occurred while trying to get list of DLCs " +
|
|
||||||
"(HTTP Status Code: %d)%n", e.getStatusCode());
|
|
||||||
System.err.println(e.getUrl());
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
|
||||||
cancel();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
cancel();
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -22,6 +22,7 @@ import kong.unirest.HttpResponse;
|
|||||||
import kong.unirest.Unirest;
|
import kong.unirest.Unirest;
|
||||||
import me.xdrop.fuzzywuzzy.FuzzySearch;
|
import me.xdrop.fuzzywuzzy.FuzzySearch;
|
||||||
import me.xdrop.fuzzywuzzy.model.BoundExtractedResult;
|
import me.xdrop.fuzzywuzzy.model.BoundExtractedResult;
|
||||||
|
import org.jsoup.HttpStatusException;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
@ -116,7 +117,7 @@ public class SteamAppsListCache {
|
|||||||
|
|
||||||
private List<App> getApps() {
|
private List<App> getApps() {
|
||||||
HttpResponse<String> httpResponse =
|
HttpResponse<String> httpResponse =
|
||||||
Unirest.get("https://api.steampowered.com/IStoreService/GetAppList/v1/" +
|
Unirest.get("https://api.steampowered.com/IStoreService/GetAppList/v2/" +
|
||||||
"?key=" + env.getKey() + "&include_games=1&max_results=50000").asString();
|
"?key=" + env.getKey() + "&include_games=1&max_results=50000").asString();
|
||||||
return new Gson()
|
return new Gson()
|
||||||
.fromJson(httpResponse.getBody(), App.Rezponze.Download.class)
|
.fromJson(httpResponse.getBody(), App.Rezponze.Download.class)
|
||||||
@ -144,12 +145,13 @@ public class SteamAppsListCache {
|
|||||||
System.out.println("Successfully got SteamAppList from file (" + cacheFile.getAbsolutePath() + ")...");
|
System.out.println("Successfully got SteamAppList from file (" + cacheFile.getAbsolutePath() + ")...");
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedHashMap<Number, String> getDlcMap(String appId) throws IOException{
|
public Map<Integer, String> getDlcMap(String appId) {
|
||||||
Map<Integer, String> steamStoreDLCs = new HashMap<>();
|
Map<Integer, String> steamStoreDLCs = new HashMap<>();
|
||||||
Map<Integer, String> steamDbDLCs = new HashMap<>();
|
Map<Integer, String> steamDbDLCs = new HashMap<>();
|
||||||
//StringBuilder sb = new StringBuilder();
|
//StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
// Steam Store
|
||||||
try {
|
try {
|
||||||
// Steam Store
|
|
||||||
Document steamDoc = Jsoup
|
Document steamDoc = Jsoup
|
||||||
.connect("https://store.steampowered.com/app/" + appId + "/")
|
.connect("https://store.steampowered.com/app/" + appId + "/")
|
||||||
.get();
|
.get();
|
||||||
@ -161,7 +163,20 @@ public class SteamAppsListCache {
|
|||||||
.text().replace("\n", "").trim();
|
.text().replace("\n", "").trim();
|
||||||
steamStoreDLCs.put(Integer.parseInt(dlc_id), dlc_name);
|
steamStoreDLCs.put(Integer.parseInt(dlc_id), dlc_name);
|
||||||
}
|
}
|
||||||
// SteamDB
|
} catch (HttpStatusException e) {
|
||||||
|
if (e.getStatusCode() == 404) {
|
||||||
|
System.err.println("App ID empty or not found! (HTTP Status Code: 404)");
|
||||||
|
} else {
|
||||||
|
System.err.printf("Error occurred while trying to get list of DLCs " +
|
||||||
|
"(HTTP Status Code: %d)%n", e.getStatusCode());
|
||||||
|
}
|
||||||
|
System.err.println(e.getUrl());
|
||||||
|
} catch (NullPointerException | IOException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
// SteamDB
|
||||||
|
try {
|
||||||
Document steamDbDoc = Jsoup
|
Document steamDbDoc = Jsoup
|
||||||
.connect("https://steamdb.info/app/" + appId + "/dlc/")
|
.connect("https://steamdb.info/app/" + appId + "/dlc/")
|
||||||
.userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0")
|
.userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0")
|
||||||
@ -177,7 +192,15 @@ public class SteamAppsListCache {
|
|||||||
}
|
}
|
||||||
steamDbDLCs.put(Integer.parseInt(dlc_id), dlc_name);
|
steamDbDLCs.put(Integer.parseInt(dlc_id), dlc_name);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException e) {
|
} catch (HttpStatusException e) {
|
||||||
|
if (e.getStatusCode() == 404) {
|
||||||
|
System.err.println("App ID empty or not found! (HTTP Status Code: 404)");
|
||||||
|
} else {
|
||||||
|
System.err.printf("Error occurred while trying to get list of DLCs " +
|
||||||
|
"(HTTP Status Code: %d)%n", e.getStatusCode());
|
||||||
|
}
|
||||||
|
System.err.println(e.getUrl());
|
||||||
|
} catch (NullPointerException | IOException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user