Add: forgesvc for Curse Mod Detection fallback
This commit is contained in:
@@ -23,7 +23,8 @@ import org.jackhuang.hmcl.game.DefaultGameRepository;
|
||||
import org.jackhuang.hmcl.mod.ModManager;
|
||||
import org.jackhuang.hmcl.task.FileDownloadTask;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.util.*;
|
||||
import org.jackhuang.hmcl.util.Logging;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||
@@ -124,9 +125,15 @@ public final class CurseCompletionTask extends Task<Void> {
|
||||
CurseMetaMod mod = JsonUtils.fromNonNullJson(result, CurseMetaMod.class);
|
||||
return file.withFileName(mod.getFileNameOnDisk()).withURL(mod.getDownloadURL());
|
||||
} catch (IOException | JsonParseException e2) {
|
||||
Logging.LOG.log(Level.WARNING, "Could not query cursemeta for deleted mods: " + file.getUrl(), e2);
|
||||
notFound.set(true);
|
||||
return file;
|
||||
try {
|
||||
String result = NetworkUtils.doGet(NetworkUtils.toURL(String.format("https://addons-ecs.forgesvc.net/api/v2/addon/%d/file/%d", file.getProjectID(), file.getFileID())));
|
||||
CurseMetaMod mod = JsonUtils.fromNonNullJson(result, CurseMetaMod.class);
|
||||
return file.withFileName(mod.getFileName()).withURL(mod.getDownloadURL());
|
||||
} catch (IOException | JsonParseException e3) {
|
||||
Logging.LOG.log(Level.WARNING, "Could not query cursemeta for deleted mods: " + file.getUrl(), e2);
|
||||
notFound.set(true);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (IOException ioe) {
|
||||
|
||||
@@ -20,18 +20,23 @@ package org.jackhuang.hmcl.mod.curse;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jackhuang.hmcl.util.Immutable;
|
||||
|
||||
/**
|
||||
* CurseMetaMod is JSON structure for
|
||||
* https://cursemeta.dries007.net/<projectID>/<fileID>.json
|
||||
* https://addons-ecs.forgesvc.net/api/v2/addon/<projectID>/file/<fileID>
|
||||
*/
|
||||
@Immutable
|
||||
public final class CurseMetaMod {
|
||||
@SerializedName("Id")
|
||||
@SerializedName(value = "Id", alternate = "id")
|
||||
private final int id;
|
||||
|
||||
@SerializedName("FileName")
|
||||
@SerializedName(value = "FileName", alternate = "fileName")
|
||||
private final String fileName;
|
||||
|
||||
@SerializedName("FileNameOnDisk")
|
||||
@SerializedName(value = "FileNameOnDisk")
|
||||
private final String fileNameOnDisk;
|
||||
|
||||
@SerializedName("DownloadURL")
|
||||
@SerializedName(value = "DownloadURL", alternate = "downloadUrl")
|
||||
private final String downloadURL;
|
||||
|
||||
public CurseMetaMod() {
|
||||
|
||||
Reference in New Issue
Block a user