2022-03-03 07:31:23 +05:30
|
|
|
#pragma once
|
|
|
|
|
2022-03-08 01:16:08 +05:30
|
|
|
#include "modplatform/helpers/NetworkModAPI.h"
|
2022-03-03 07:31:23 +05:30
|
|
|
|
2022-03-07 01:15:39 +05:30
|
|
|
#include <QDebug>
|
|
|
|
|
2022-03-08 01:16:08 +05:30
|
|
|
class ModrinthAPI : public NetworkModAPI {
|
2022-03-03 07:31:23 +05:30
|
|
|
public:
|
2022-03-08 19:42:35 +05:30
|
|
|
inline auto getAuthorURL(const QString& name) const -> QString { return "https://modrinth.com/user/" + name; };
|
2022-03-08 00:52:57 +05:30
|
|
|
|
|
|
|
private:
|
2022-03-08 19:42:35 +05:30
|
|
|
inline auto getModSearchURL(SearchArgs& args) const -> QString override
|
2022-03-08 00:52:57 +05:30
|
|
|
{
|
|
|
|
if (!validateModLoader(args.mod_loader)) {
|
2022-03-07 01:15:39 +05:30
|
|
|
qWarning() << "Modrinth only have Forge and Fabric-compatible mods!";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2022-03-08 00:52:57 +05:30
|
|
|
return QString(
|
|
|
|
"https://api.modrinth.com/v2/search?"
|
|
|
|
"offset=%1&"
|
|
|
|
"limit=25&"
|
|
|
|
"query=%2&"
|
|
|
|
"index=%3&"
|
|
|
|
"facets=[[\"categories:%4\"],[\"versions:%5\"],[\"project_type:mod\"]]")
|
|
|
|
.arg(args.offset)
|
|
|
|
.arg(args.search)
|
|
|
|
.arg(args.sorting)
|
|
|
|
.arg(getModLoaderString(args.mod_loader))
|
|
|
|
.arg(args.version);
|
2022-03-03 07:31:23 +05:30
|
|
|
};
|
|
|
|
|
2022-03-08 19:42:35 +05:30
|
|
|
inline auto getVersionsURL(const QString& addonId) const -> QString override
|
2022-03-03 07:31:23 +05:30
|
|
|
{
|
|
|
|
return QString("https://api.modrinth.com/v2/project/%1/version").arg(addonId);
|
|
|
|
};
|
|
|
|
|
2022-03-08 19:42:35 +05:30
|
|
|
inline auto getModLoaderString(ModLoaderType modLoader) const -> QString
|
2022-03-08 00:52:57 +05:30
|
|
|
{
|
|
|
|
switch (modLoader) {
|
|
|
|
case Any:
|
|
|
|
return "fabric, forge";
|
|
|
|
case Forge:
|
|
|
|
return "forge";
|
|
|
|
case Fabric:
|
|
|
|
return "fabric";
|
|
|
|
default:
|
|
|
|
return "";
|
2022-03-07 01:15:39 +05:30
|
|
|
}
|
|
|
|
}
|
2022-03-08 01:16:08 +05:30
|
|
|
|
2022-03-08 19:42:35 +05:30
|
|
|
inline auto validateModLoader(ModLoaderType modLoader) const -> bool
|
2022-03-08 01:16:08 +05:30
|
|
|
{
|
|
|
|
return modLoader == Any || modLoader == Forge || modLoader == Fabric;
|
|
|
|
}
|
|
|
|
|
2022-03-03 07:31:23 +05:30
|
|
|
};
|