Added a method to clean filenames before scraping

This commit is contained in:
Juan Pablo 2013-09-24 02:20:53 -03:00
parent 57eb9849ff
commit 3e1ecb4a84
4 changed files with 9 additions and 2 deletions

View file

@ -1,5 +1,6 @@
#include "GameData.h" #include "GameData.h"
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/regex/v4/regex.hpp>
#include <iostream> #include <iostream>
#include <ctime> #include <ctime>
#include <sstream> #include <sstream>
@ -57,6 +58,11 @@ std::string GameData::getBaseName() const
return mBaseName; return mBaseName;
} }
std::string GameData::getCleanName() const
{
return regex_replace(mBaseName, boost::regex("\\((.*)\\)|\\[(.*)\\]"), "");
}
void GameData::incTimesPlayed() void GameData::incTimesPlayed()
{ {
int timesPlayed = metadata()->getInt("playcount"); int timesPlayed = metadata()->getInt("playcount");

View file

@ -21,6 +21,7 @@ public:
std::string getBashPath() const; std::string getBashPath() const;
std::string getBaseName() const; std::string getBaseName() const;
std::string getCleanName() const;
bool isFolder() const override; bool isFolder() const override;

View file

@ -69,7 +69,7 @@ GuiGameScraper::GuiGameScraper(Window* window, ScraperSearchParams params, std::
//y = 3 is a spacer row //y = 3 is a spacer row
mList.setEntry(Vector2i(0, 4), Vector2i(1, 1), &mSearchLabel, false, ComponentListComponent::AlignLeft); 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()); mSearchText.setSize(colWidth * 2 - mSearchLabel.getSize().x() - 20, mSearchText.getSize().y());
mList.setEntry(Vector2i(1, 4), Vector2i(1, 1), &mSearchText, true, ComponentListComponent::AlignRight); mList.setEntry(Vector2i(1, 4), Vector2i(1, 1), &mSearchText, true, ComponentListComponent::AlignRight);

View file

@ -18,7 +18,7 @@ std::shared_ptr<HttpReq> GamesDBScraper::makeHttpReq(ScraperSearchParams params)
std::string cleanName = params.nameOverride; std::string cleanName = params.nameOverride;
if(cleanName.empty()) if(cleanName.empty())
cleanName = params.game->getBaseName(); cleanName = params.game->getCleanName();
path += "name=" + cleanName; path += "name=" + cleanName;
//platform TODO, should use some params.system get method //platform TODO, should use some params.system get method