Skip to content

Commit

Permalink
remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
PoloNX committed Oct 7, 2023
1 parent dbae543 commit 1cfaf85
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion include/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace utils {
nlohmann::json getInstalledGames();
nlohmann::json searchGames(std::string gameTitle);
std::string replaceSpacesWithPlus(const std::string& str);
nlohmann::json getMods(const int& gameID, int& page);
nlohmann::json getMods(const int& gameID, const std::string& search, int& page);
nlohmann::json getDownloadLinks(const std::string& ModelName, const int& idRow);
Expand Down
17 changes: 8 additions & 9 deletions source/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,12 @@ namespace utils {
auto curl = curl_easy_init();
if(curl) {
gameTitle = curl_easy_escape(curl, gameTitle.c_str(), 0);
curl_easy_cleanup(curl);
}
}

brls::Logger::info("Game title: {}", gameTitle);

gameTitle = replaceSpacesWithPlus(gameTitle);

const std::string api_url = fmt::format("https://gamebanana.com/apiv11/Util/Game/NameMatch?_sName={}", gameTitle);
brls::Logger::debug("API URL: {}", api_url);

Expand All @@ -136,12 +135,6 @@ namespace utils {
return games;
}

std::string replaceSpacesWithPlus(const std::string& str) {
std::string resultString = str;
std::ranges::replace(resultString, ' ', '+');
return resultString;
}

nlohmann::json getMods(const int& gameID, int& page) {
if(page < 1) page = 1;
std::string api_url = fmt::format("https://gamebanana.com/apiv11/Game/{}/Subfeed?_nPage={}?_nPerpage=50&_csvModelInclusions=Mod", std::to_string(gameID), std::to_string(page));
Expand All @@ -163,7 +156,13 @@ namespace utils {
brls::Application::notify("menu/notify/string_to_short"_i18n);
return getMods(gameID, page);
}
std::string search_term = replaceSpacesWithPlus(search);

std::string search_term = search;
auto curl = curl_easy_init();
if(curl){
search_term = curl_easy_escape(curl, search.c_str(), 0);
curl_easy_cleanup(curl);
}
std::string api_url = fmt::format("https://gamebanana.com/apiv11/Game/{}/Subfeed?_nPage={}&_nPerpage=50&_sName={}&_csvModelInclusions=Mod", std::to_string(gameID),std::to_string(page), search_term);
nlohmann::json mods = net::downloadRequest(api_url);
if(mods.at("_aRecords").empty() && page > 1) {
Expand Down

0 comments on commit 1cfaf85

Please sign in to comment.