2020-05-26 16:34:33 +00:00
|
|
|
//
|
|
|
|
// GamesDBJSONScraperResources.h
|
|
|
|
//
|
|
|
|
// Functions specifically for scraping from thegamesdb.net
|
|
|
|
// Called from GamesDBJSONScraper.
|
|
|
|
//
|
|
|
|
|
2019-02-08 02:08:11 +00:00
|
|
|
#pragma once
|
|
|
|
#ifndef ES_APP_SCRAPERS_GAMES_DB_JSON_SCRAPER_RESOURCES_H
|
|
|
|
#define ES_APP_SCRAPERS_GAMES_DB_JSON_SCRAPER_RESOURCES_H
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include "HttpReq.h"
|
|
|
|
|
2020-05-26 16:34:33 +00:00
|
|
|
struct TheGamesDBJSONRequestResources {
|
2019-02-08 02:08:11 +00:00
|
|
|
TheGamesDBJSONRequestResources() = default;
|
|
|
|
|
|
|
|
void prepare();
|
|
|
|
void ensureResources();
|
|
|
|
std::string getApiKey() const;
|
|
|
|
|
|
|
|
std::unordered_map<int, std::string> gamesdb_new_developers_map;
|
|
|
|
std::unordered_map<int, std::string> gamesdb_new_publishers_map;
|
|
|
|
std::unordered_map<int, std::string> gamesdb_new_genres_map;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool checkLoaded();
|
|
|
|
|
2020-05-26 16:34:33 +00:00
|
|
|
bool saveResource(
|
|
|
|
HttpReq* req,
|
|
|
|
std::unordered_map<int, std::string>& resource,
|
|
|
|
const std::string& resource_name,
|
|
|
|
const std::string& file_name);
|
|
|
|
std::unique_ptr<HttpReq> fetchResource(const std::string& endpoint);
|
2019-02-08 02:08:11 +00:00
|
|
|
|
|
|
|
int loadResource(
|
2020-05-26 16:34:33 +00:00
|
|
|
std::unordered_map<int, std::string>& resource,
|
|
|
|
const std::string& resource_name,
|
|
|
|
const std::string& file_name);
|
2019-02-08 02:08:11 +00:00
|
|
|
|
|
|
|
std::unique_ptr<HttpReq> gamesdb_developers_resource_request;
|
|
|
|
std::unique_ptr<HttpReq> gamesdb_publishers_resource_request;
|
|
|
|
std::unique_ptr<HttpReq> gamesdb_genres_resource_request;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string getScrapersResouceDir();
|
|
|
|
|
2020-05-26 16:34:33 +00:00
|
|
|
#endif // ES_APP_SCRAPERS_GAMES_DB_JSON_SCRAPER_RESOURCES_H
|