Fixed bracket and parenthesis removal for games not found in the meta database.

This commit is contained in:
Pieter Hulshoff 2017-03-31 09:15:42 +02:00
parent afeb633f9e
commit 32382464f8
2 changed files with 47 additions and 41 deletions

View File

@ -228,13 +228,6 @@ void MetadataDatabase::injectMetadata(CollectionInfo *collection)
int rc;
sqlite3_stmt *stmt;
bool showParenthesis = true;
bool showSquareBrackets = true;
(void)config_.getProperty("showParenthesis", showParenthesis);
(void)config_.getProperty("showSquareBrackets", showSquareBrackets);
// items into a hash to make it easily searchable
std::vector<Item *> *items = &collection->items;
std::map<std::string, Item *> itemMap;
@ -272,40 +265,6 @@ void MetadataDatabase::injectMetadata(CollectionInfo *collection)
std::string launcher;
std::string title = fullTitle;
//todo: this should be a helper method, peformed both in CollectionInfoBuilder
if(!showParenthesis)
{
std::string::size_type firstPos = title.find_first_of("(");
std::string::size_type secondPos = title.find_first_of(")", firstPos);
while(firstPos != std::string::npos && secondPos != std::string::npos)
{
firstPos = title.find_first_of("(");
secondPos = title.find_first_of(")", firstPos);
if (firstPos != std::string::npos)
{
title.erase(firstPos, (secondPos - firstPos) + 1);
}
}
}
if(!showSquareBrackets)
{
std::string::size_type firstPos = title.find_first_of("[");
std::string::size_type secondPos = title.find_first_of("]", firstPos);
while(firstPos != std::string::npos && secondPos != std::string::npos)
{
firstPos = title.find_first_of("[");
secondPos = title.find_first_of("]", firstPos);
if (firstPos != std::string::npos && secondPos != std::string::npos)
{
title.erase(firstPos, (secondPos - firstPos) + 1);
}
}
}
std::map<std::string, Item *>::iterator it = itemMap.find(name);
if(it != itemMap.end())

View File

@ -948,6 +948,53 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
cib.addPlaylists(collection);
collection->sortFavoriteItems();
// Remove parenthesis and brackets, if so configured
bool showParenthesis = true;
bool showSquareBrackets = true;
(void)config_.getProperty("showParenthesis", showParenthesis);
(void)config_.getProperty("showSquareBrackets", showSquareBrackets);
typedef std::map<std::string, std::vector <Item *> *> Playlists_T;
for(Playlists_T::iterator itP = collection->playlists.begin(); itP != collection->playlists.end(); itP++)
{
for(std::vector <Item *>::iterator itI = itP->second->begin(); itI != itP->second->end(); itI++)
{
if(!showParenthesis)
{
std::string::size_type firstPos = (*itI)->title.find_first_of("(");
std::string::size_type secondPos = (*itI)->title.find_first_of(")", firstPos);
while(firstPos != std::string::npos && secondPos != std::string::npos)
{
firstPos = (*itI)->title.find_first_of("(");
secondPos = (*itI)->title.find_first_of(")", firstPos);
if (firstPos != std::string::npos)
{
(*itI)->title.erase(firstPos, (secondPos - firstPos) + 1);
}
}
}
if(!showSquareBrackets)
{
std::string::size_type firstPos = (*itI)->title.find_first_of("[");
std::string::size_type secondPos = (*itI)->title.find_first_of("]", firstPos);
while(firstPos != std::string::npos && secondPos != std::string::npos)
{
firstPos = (*itI)->title.find_first_of("[");
secondPos = (*itI)->title.find_first_of("]", firstPos);
if (firstPos != std::string::npos && secondPos != std::string::npos)
{
(*itI)->title.erase(firstPos, (secondPos - firstPos) + 1);
}
}
}
}
}
return collection;
}