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:
parent
52c45c2d32
commit
a7648d60ce
@ -55,11 +55,11 @@ struct IndexedVersion {
|
|||||||
QVariant fileId;
|
QVariant fileId;
|
||||||
QString version;
|
QString version;
|
||||||
QString version_number = {};
|
QString version_number = {};
|
||||||
QVector<QString> mcVersion;
|
QStringList mcVersion;
|
||||||
QString downloadUrl;
|
QString downloadUrl;
|
||||||
QString date;
|
QString date;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
QVector<QString> loaders = {};
|
QStringList loaders = {};
|
||||||
QString hash_type;
|
QString hash_type;
|
||||||
QString hash;
|
QString hash;
|
||||||
bool is_preferred = true;
|
bool is_preferred = true;
|
||||||
@ -79,6 +79,7 @@ struct IndexedPack {
|
|||||||
QVariant addonId;
|
QVariant addonId;
|
||||||
Provider provider;
|
Provider provider;
|
||||||
QString name;
|
QString name;
|
||||||
|
QString slug;
|
||||||
QString description;
|
QString description;
|
||||||
QList<ModpackAuthor> authors;
|
QList<ModpackAuthor> authors;
|
||||||
QString logoName;
|
QString logoName;
|
||||||
|
@ -14,14 +14,15 @@ void FlameMod::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
|||||||
pack.addonId = Json::requireInteger(obj, "id");
|
pack.addonId = Json::requireInteger(obj, "id");
|
||||||
pack.provider = ModPlatform::Provider::FLAME;
|
pack.provider = ModPlatform::Provider::FLAME;
|
||||||
pack.name = Json::requireString(obj, "name");
|
pack.name = Json::requireString(obj, "name");
|
||||||
|
pack.slug = Json::requireString(obj, "slug");
|
||||||
pack.websiteUrl = Json::ensureString(Json::ensureObject(obj, "links"), "websiteUrl", "");
|
pack.websiteUrl = Json::ensureString(Json::ensureObject(obj, "links"), "websiteUrl", "");
|
||||||
pack.description = Json::ensureString(obj, "summary", "");
|
pack.description = Json::ensureString(obj, "summary", "");
|
||||||
|
|
||||||
QJsonObject logo = Json::requireObject(obj, "logo");
|
QJsonObject logo = Json::ensureObject(obj, "logo");
|
||||||
pack.logoName = Json::requireString(logo, "title");
|
pack.logoName = Json::ensureString(logo, "title");
|
||||||
pack.logoUrl = Json::requireString(logo, "thumbnailUrl");
|
pack.logoUrl = Json::ensureString(logo, "thumbnailUrl");
|
||||||
|
|
||||||
auto authors = Json::requireArray(obj, "authors");
|
auto authors = Json::ensureArray(obj, "authors");
|
||||||
for (auto authorIter : authors) {
|
for (auto authorIter : authors) {
|
||||||
auto author = Json::requireObject(authorIter);
|
auto author = Json::requireObject(authorIter);
|
||||||
ModPlatform::ModpackAuthor packAuthor;
|
ModPlatform::ModpackAuthor packAuthor;
|
||||||
|
@ -29,13 +29,16 @@ static ModPlatform::ProviderCapabilities ProviderCaps;
|
|||||||
|
|
||||||
void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
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.provider = ModPlatform::Provider::MODRINTH;
|
||||||
pack.name = Json::requireString(obj, "title");
|
pack.name = Json::requireString(obj, "title");
|
||||||
|
|
||||||
QString slug = Json::ensureString(obj, "slug", "");
|
pack.slug = Json::ensureString(obj, "slug", "");
|
||||||
if (!slug.isEmpty())
|
if (!pack.slug.isEmpty())
|
||||||
pack.websiteUrl = "https://modrinth.com/mod/" + Json::ensureString(obj, "slug", "");
|
pack.websiteUrl = "https://modrinth.com/mod/" + pack.slug;
|
||||||
else
|
else
|
||||||
pack.websiteUrl = "";
|
pack.websiteUrl = "";
|
||||||
|
|
||||||
@ -45,7 +48,7 @@ void Modrinth::loadIndexedPack(ModPlatform::IndexedPack& pack, QJsonObject& obj)
|
|||||||
pack.logoName = pack.addonId.toString();
|
pack.logoName = pack.addonId.toString();
|
||||||
|
|
||||||
ModPlatform::ModpackAuthor modAuthor;
|
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);
|
modAuthor.url = api.getAuthorURL(modAuthor.name);
|
||||||
pack.authors.append(modAuthor);
|
pack.authors.append(modAuthor);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user