mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00:00
Update to new ContentDB API
This commit is contained in:
parent
e8b687d7ca
commit
ca502fc274
4 changed files with 35 additions and 42 deletions
|
@ -43,24 +43,19 @@ std::vector<Package> getPackagesFromURL(const std::string &url)
|
|||
for (unsigned int i = 0; i < json.size(); ++i) {
|
||||
Package package;
|
||||
|
||||
package.author = json[i]["author"].asString();
|
||||
package.name = json[i]["name"].asString();
|
||||
package.title = json[i]["title"].asString();
|
||||
package.author = json[i]["author"].asString();
|
||||
package.type = json[i]["type"].asString();
|
||||
package.shortDesc = json[i]["shortDesc"].asString();
|
||||
package.url = json[i]["url"].asString();
|
||||
package.release = json[i]["release"].asInt();
|
||||
if (json[i].isMember("thumbnail"))
|
||||
package.thumbnail = json[i]["thumbnail"].asString();
|
||||
|
||||
Json::Value jScreenshots = json[i]["screenshots"];
|
||||
for (unsigned int j = 0; j < jScreenshots.size(); ++j) {
|
||||
package.screenshots.push_back(jScreenshots[j].asString());
|
||||
}
|
||||
|
||||
if (package.valid()) {
|
||||
if (package.valid())
|
||||
packages.push_back(package);
|
||||
} else {
|
||||
else
|
||||
errorstream << "Invalid package at " << i << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
return packages;
|
||||
|
|
|
@ -24,20 +24,24 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
struct Package
|
||||
{
|
||||
std::string author;
|
||||
std::string name; // Technical name
|
||||
std::string title;
|
||||
std::string author;
|
||||
std::string type; // One of "mod", "game", or "txp"
|
||||
|
||||
std::string shortDesc;
|
||||
std::string url; // download URL
|
||||
u32 release;
|
||||
std::vector<std::string> screenshots;
|
||||
std::string thumbnail;
|
||||
|
||||
bool valid()
|
||||
bool valid() const
|
||||
{
|
||||
return !(name.empty() || title.empty() || author.empty() ||
|
||||
type.empty() || url.empty() || release <= 0);
|
||||
return !(author.empty() || name.empty() || title.empty() ||
|
||||
type.empty() || release <= 0);
|
||||
}
|
||||
|
||||
std::string getDownloadURL(const std::string &baseURL) const
|
||||
{
|
||||
return baseURL + "/packages/" + author + "/" + name + "/download/";
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue