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 org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||
import org.jsoup.HttpStatusException;
|
||||
import xyz.jeddunk.autocreamapi.pojo.App;
|
||||
import xyz.jeddunk.autocreamapi.util.CreamApiConfig;
|
||||
import xyz.jeddunk.autocreamapi.util.CreamApiDllHandler;
|
||||
@ -303,7 +302,8 @@ public class Controller implements Initializable {
|
||||
appId_textfield.setText(String.valueOf(game.getAppId()));
|
||||
} else {
|
||||
try {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("searchResultWindow.fxml"));
|
||||
URL resource = ClassLoader.getSystemResource("searchResultWindow.fxml");
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(resource);
|
||||
Parent root1 = fxmlLoader.load();
|
||||
|
||||
SearchResultWindowController c = fxmlLoader.getController();
|
||||
@ -338,26 +338,10 @@ public class Controller implements Initializable {
|
||||
return new Task<Void>() {
|
||||
@Override
|
||||
protected Void call() {
|
||||
try {
|
||||
Map<Number, String> collect = cache.getDlcMap(appId_textfield.getText());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n"));
|
||||
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();
|
||||
}
|
||||
Map<Integer, String> collect = cache.getDlcMap(appId_textfield.getText());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
collect.forEach((k, v) -> sb.append(k).append("=").append(v).append("\n"));
|
||||
dlc_textarea.setText(sb.toString());
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
@ -22,6 +22,7 @@ import kong.unirest.HttpResponse;
|
||||
import kong.unirest.Unirest;
|
||||
import me.xdrop.fuzzywuzzy.FuzzySearch;
|
||||
import me.xdrop.fuzzywuzzy.model.BoundExtractedResult;
|
||||
import org.jsoup.HttpStatusException;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
@ -116,7 +117,7 @@ public class SteamAppsListCache {
|
||||
|
||||
private List<App> getApps() {
|
||||
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();
|
||||
return new Gson()
|
||||
.fromJson(httpResponse.getBody(), App.Rezponze.Download.class)
|
||||
@ -144,12 +145,13 @@ public class SteamAppsListCache {
|
||||
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> steamDbDLCs = new HashMap<>();
|
||||
//StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Steam Store
|
||||
try {
|
||||
// Steam Store
|
||||
Document steamDoc = Jsoup
|
||||
.connect("https://store.steampowered.com/app/" + appId + "/")
|
||||
.get();
|
||||
@ -161,7 +163,20 @@ public class SteamAppsListCache {
|
||||
.text().replace("\n", "").trim();
|
||||
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
|
||||
.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")
|
||||
@ -177,7 +192,15 @@ public class SteamAppsListCache {
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user