flycast/core/rend/boxart/gamesdb.h

50 lines
1.7 KiB
C
Raw Normal View History

2022-06-15 19:22:12 +00:00
/*
Copyright 2022 flyinghead
This file is part of Flycast.
Flycast is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
Flycast is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
*/
#include <map>
#include "scraper.h"
#include "json.hpp"
using namespace nlohmann;
class TheGamesDb : public Scraper
{
public:
bool initialize(const std::string& saveDirectory) override;
void scrape(GameBoxart& item) override;
void scrape(std::vector<GameBoxart>& items) override;
2022-06-15 19:22:12 +00:00
~TheGamesDb();
private:
void fetchPlatforms();
bool fetchGameInfo(GameBoxart& item, const std::string& url, const std::string& diskId = "");
2022-06-15 19:22:12 +00:00
std::string makeUrl(const std::string& endpoint);
void copyFile(const std::string& from, const std::string& to);
json httpGet(const std::string& url);
void parseBoxart(GameBoxart& item, const json& j, int gameId);
void fetchByUids(std::vector<GameBoxart>& items);
void fetchByName(GameBoxart& item);
bool parseGameInfo(const json& gameArray, const json& boxartArray, GameBoxart& item, const std::string& diskId);
2022-06-15 19:22:12 +00:00
int dreamcastPlatformId = 0;
int arcadePlatformId = 0;
2022-06-15 19:22:12 +00:00
double blackoutPeriod = 0.0;
std::map<std::string, std::string> boxartCache; // key: url, value: local file path
};