Do the url trick on initial modpack download too

This commit is contained in:
timoreo 2022-05-21 08:31:07 +02:00
parent 92e8aaf36f
commit c04adf7452
No known key found for this signature in database
GPG Key ID: 121A72C3512BA288
2 changed files with 10 additions and 1 deletions

View File

@ -65,7 +65,15 @@ void Flame::loadIndexedPackVersions(Flame::IndexedPack& pack, QJsonArray& arr)
// pick the latest version supported
file.mcVersion = versionArray[0].toString();
file.version = Json::requireString(version, "displayName");
file.downloadUrl = Json::requireString(version, "downloadUrl");
file.fileName = Json::requireString(version, "fileName");
file.downloadUrl = Json::ensureString(version, "downloadUrl");
if(file.downloadUrl.isEmpty()){
//FIXME : HACK, MAY NOT WORK FOR LONG
file.downloadUrl = QString("https://media.forgecdn.net/files/%1/%2/%3")
.arg(QString::number(QString::number(file.fileId).leftRef(4).toInt())
,QString::number(QString::number(file.fileId).rightRef(3).toInt())
,QUrl::toPercentEncoding(file.fileName));
}
unsortedVersions.append(file);
}

View File

@ -18,6 +18,7 @@ struct IndexedVersion {
QString version;
QString mcVersion;
QString downloadUrl;
QString fileName;
};
struct IndexedPack