mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-10 00:01:28 +01:00
Fixed bracket and parenthesis removal for games not found in the meta database.
This commit is contained in:
parent
afeb633f9e
commit
32382464f8
@ -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())
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user