mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-06-07 11:26:48 +02:00
Fixed bracket and parenthesis removal for games not found in the meta database.
This commit is contained in:
@@ -228,13 +228,6 @@ void MetadataDatabase::injectMetadata(CollectionInfo *collection)
|
|||||||
int rc;
|
int rc;
|
||||||
sqlite3_stmt *stmt;
|
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
|
// items into a hash to make it easily searchable
|
||||||
std::vector<Item *> *items = &collection->items;
|
std::vector<Item *> *items = &collection->items;
|
||||||
std::map<std::string, Item *> itemMap;
|
std::map<std::string, Item *> itemMap;
|
||||||
@@ -272,40 +265,6 @@ void MetadataDatabase::injectMetadata(CollectionInfo *collection)
|
|||||||
std::string launcher;
|
std::string launcher;
|
||||||
std::string title = fullTitle;
|
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);
|
std::map<std::string, Item *>::iterator it = itemMap.find(name);
|
||||||
|
|
||||||
if(it != itemMap.end())
|
if(it != itemMap.end())
|
||||||
|
|||||||
@@ -948,6 +948,53 @@ CollectionInfo *RetroFE::getCollection(std::string collectionName)
|
|||||||
cib.addPlaylists(collection);
|
cib.addPlaylists(collection);
|
||||||
collection->sortFavoriteItems();
|
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;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user