fix: don't require non-essential items in mod index

Also adds slug field.

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-06-19 14:31:44 -03:00
parent 52c45c2d32
commit a7648d60ce
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
3 changed files with 16 additions and 11 deletions

View File

@ -55,11 +55,11 @@ struct IndexedVersion {
QVariant fileId;
QString version;
QString version_number = {};
QVector<QString> mcVersion;
QStringList mcVersion;
QString downloadUrl;
QString date;
QString fileName;
QVector<QString> loaders = {};
QStringList loaders = {};
QString hash_type;
QString hash;
bool is_preferred = true;
@ -79,6 +79,7 @@ struct IndexedPack {
QVariant addonId;
Provider provider;
QString name;
QString slug;
QString description;
QList<ModpackAuthor> authors;
QString logoName;

View File

@ -14,14 +14,15 @@ void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
pack.addonId = Json::requireInteger(obj, "id");
pack.provider = ModPlatform::Provider::FLAME;
pack.name = Json::requireString(obj, "name");
pack.slug = Json::requireString(obj, "slug");
pack.websiteUrl = Json::ensureString(Json::ensureObject(obj, "links"), "websiteUrl", "");
pack.description = Json::ensureString(obj, "summary", "");
QJsonObject logo = Json::requireObject(obj, "logo");
pack.logoName = Json::requireString(logo, "title");
pack.logoUrl = Json::requireString(logo, "thumbnailUrl");
QJsonObject logo = Json::ensureObject(obj, "logo");
pack.logoName = Json::ensureString(logo, "title");
pack.logoUrl = Json::ensureString(logo, "thumbnailUrl");
auto authors = Json::requireArray(obj, "authors");
auto authors = Json::ensureArray(obj, "authors");
for (auto authorIter : authors) {
auto author = Json::requireObject(authorIter);
ModPlatform::ModpackAuthor packAuthor;

View File

@ -29,13 +29,16 @@ static ModPlatform::ProviderCapabilities ProviderCaps;
void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
{
pack.addonId = Json::requireString(obj, "project_id");
pack.addonId = Json::ensureString(obj, "project_id");
if (pack.addonId.toString().isEmpty())
pack.addonId = Json::requireString(obj, "id");
pack.provider = ModPlatform::Provider::MODRINTH;
pack.name = Json::requireString(obj, "title");
QString slug = Json::ensureString(obj, "slug", "");
if (!slug.isEmpty())
pack.websiteUrl = "https://modrinth.com/mod/" + Json::ensureString(obj, "slug", "");
pack.slug = Json::ensureString(obj, "slug", "");
if (!pack.slug.isEmpty())
pack.websiteUrl = "https://modrinth.com/mod/" + pack.slug;
else
pack.websiteUrl = "";
@ -45,7 +48,7 @@ void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
pack.logoName = pack.addonId.toString();
ModPlatform::ModpackAuthor modAuthor;
modAuthor.name = Json::requireString(obj, "author");
modAuthor.name = Json::ensureString(obj, "author", QObject::tr("No author(s)"));
modAuthor.url = api.getAuthorURL(modAuthor.name);
pack.authors.append(modAuthor);