mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-16 08:05:34 -04:00
Fix[modpack-download]: fallback url
This commit is contained in:
parent
08f16f50cc
commit
5c556c1382
@ -190,11 +190,20 @@ public class CurseforgeApi implements ModpackApi{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getDownloadUrl(long projectID, long fileID) {
|
private String getDownloadUrl(long projectID, long fileID) {
|
||||||
|
// First try the official api endpoint
|
||||||
JsonObject response = mApiHandler.get("mods/"+projectID+"/files/"+fileID+"/download-url", JsonObject.class);
|
JsonObject response = mApiHandler.get("mods/"+projectID+"/files/"+fileID+"/download-url", JsonObject.class);
|
||||||
if(response == null) return null;
|
if (response != null && !response.get("data").isJsonNull())
|
||||||
JsonElement data = response.get("data");
|
return response.get("data").getAsString();
|
||||||
if(data == null || data.isJsonNull()) return null;
|
|
||||||
return data.getAsString();
|
// Otherwise, fallback to building an edge link
|
||||||
|
JsonObject fallbackResponse = mApiHandler.get(String.format("mods/%s/files/%s", projectID, fileID), JsonObject.class);
|
||||||
|
if (fallbackResponse != null && !fallbackResponse.get("data").isJsonNull()){
|
||||||
|
JsonObject modData = fallbackResponse.get("data").getAsJsonObject();
|
||||||
|
int id = modData.get("id").getAsInt();
|
||||||
|
return String.format("https://edge.forgecdn.net/files/%s/%s/%s", id/1000, id % 1000, modData.get("fileName").getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean verifyManifest(CurseManifest manifest) {
|
private boolean verifyManifest(CurseManifest manifest) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user