Merge pull request #207 from flowln/curseforge_api
This commit is contained in:
commit
139ff82432
@ -50,42 +50,43 @@ void FlameMod::loadIndexedPackVersions(FlameMod::IndexedPack & pack, QJsonArray
|
||||
|
||||
for(auto versionIter: arr) {
|
||||
auto obj = versionIter.toObject();
|
||||
FlameMod::IndexedVersion file;
|
||||
file.addonId = pack.addonId;
|
||||
file.fileId = Json::requireInteger(obj, "id");
|
||||
file.date = Json::requireString(obj, "fileDate");
|
||||
|
||||
auto versionArray = Json::requireArray(obj, "gameVersion");
|
||||
if (versionArray.empty()) {
|
||||
if (versionArray.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FlameMod::IndexedVersion file;
|
||||
for(auto mcVer : versionArray){
|
||||
file.mcVersion.append(mcVer.toString());
|
||||
}
|
||||
|
||||
file.addonId = pack.addonId;
|
||||
file.fileId = Json::requireInteger(obj, "id");
|
||||
file.date = Json::requireString(obj, "fileDate");
|
||||
file.version = Json::requireString(obj, "displayName");
|
||||
file.downloadUrl = Json::requireString(obj, "downloadUrl");
|
||||
file.fileName = Json::requireString(obj, "fileName");
|
||||
|
||||
auto modules = Json::requireArray(obj, "modules");
|
||||
bool valid = false;
|
||||
bool is_valid_fabric_version = false;
|
||||
for(auto m : modules){
|
||||
auto fname = Json::requireString(m.toObject(),"foldername");
|
||||
// FIXME: This does not work properly when a mod supports more than one mod loader, since
|
||||
// they bundle the meta files for all of them in the same arquive, even when that version
|
||||
// doesn't support the given mod loader.
|
||||
if(hasFabric){
|
||||
if(fname == "fabric.mod.json"){
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
//this cannot check for the recent mcmod.toml formats
|
||||
if(fname == "mcmod.info"){
|
||||
valid = true;
|
||||
is_valid_fabric_version = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else break;
|
||||
// NOTE: Since we're not validating forge versions, we can just skip this loop.
|
||||
}
|
||||
if(!valid && hasFabric){
|
||||
|
||||
if(hasFabric && !is_valid_fabric_version)
|
||||
continue;
|
||||
}
|
||||
|
||||
unsortedVersions.append(file);
|
||||
}
|
||||
|
@ -175,13 +175,13 @@ void ListModel::performPaginatedSearch()
|
||||
"pageSize=25&"
|
||||
"searchFilter=%2&"
|
||||
"sort=%3&"
|
||||
"%4"
|
||||
"modLoaderType=%4&"
|
||||
"gameVersion=%5"
|
||||
)
|
||||
.arg(nextSearchOffset)
|
||||
.arg(currentSearchTerm)
|
||||
.arg(sorts[currentSort])
|
||||
.arg(hasFabric ? "modLoaderType=4&" : "")
|
||||
.arg(hasFabric ? 4 : 1) // Enum: https://docs.curseforge.com/?http#tocS_ModLoaderType
|
||||
.arg(mcVersion);
|
||||
|
||||
netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response));
|
||||
|
Loading…
Reference in New Issue
Block a user