mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 08:05:38 +00:00
Added a method to clean filenames before scraping
This commit is contained in:
parent
57eb9849ff
commit
3e1ecb4a84
|
@ -1,5 +1,6 @@
|
|||
#include "GameData.h"
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/regex/v4/regex.hpp>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
|
@ -57,6 +58,11 @@ std::string GameData::getBaseName() const
|
|||
return mBaseName;
|
||||
}
|
||||
|
||||
std::string GameData::getCleanName() const
|
||||
{
|
||||
return regex_replace(mBaseName, boost::regex("\\((.*)\\)|\\[(.*)\\]"), "");
|
||||
}
|
||||
|
||||
void GameData::incTimesPlayed()
|
||||
{
|
||||
int timesPlayed = metadata()->getInt("playcount");
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
|
||||
std::string getBashPath() const;
|
||||
std::string getBaseName() const;
|
||||
std::string getCleanName() const;
|
||||
|
||||
bool isFolder() const override;
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::
|
|||
//y = 3 is a spacer row
|
||||
|
||||
mList.setEntry(Vector2i(0, 4), Vector2i(1, 1), &mSearchLabel, false, ComponentListComponent::AlignLeft);
|
||||
mSearchText.setValue(!params.nameOverride.empty() ? params.nameOverride : params.game->getBaseName());
|
||||
mSearchText.setValue(!params.nameOverride.empty() ? params.nameOverride : params.game->getCleanName());
|
||||
mSearchText.setSize(colWidth * 2 - mSearchLabel.getSize().x() - 20, mSearchText.getSize().y());
|
||||
mList.setEntry(Vector2i(1, 4), Vector2i(1, 1), &mSearchText, true, ComponentListComponent::AlignRight);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ std::shared_ptr<HttpReq> GamesDBScraper::makeHttpReq(ScraperSearchParams params)
|
|||
|
||||
std::string cleanName = params.nameOverride;
|
||||
if(cleanName.empty())
|
||||
cleanName = params.game->getBaseName();
|
||||
cleanName = params.game->getCleanName();
|
||||
|
||||
path += "name=" + cleanName;
|
||||
//platform TODO, should use some params.system get method
|
||||
|
|
Loading…
Reference in a new issue