Skip to content
Browse files

FIX: Allow both prepend and append in advancedsettings' "tvshowmatching"

  • Loading branch information...
1 parent 95b0749 commit 79056b7b1142c280444e66db30cea0788bf8f3d5 @koying committed Oct 25, 2012
Showing with 45 additions and 39 deletions.
  1. +45 −39 xbmc/settings/AdvancedSettings.cpp
View
84 xbmc/settings/AdvancedSettings.cpp
@@ -1066,52 +1066,58 @@ void CAdvancedSettings::Clear()
void CAdvancedSettings::GetCustomTVRegexps(TiXmlElement *pRootElement, SETTINGS_TVSHOWLIST& settings)
{
- int iAction = 0; // overwrite
- // for backward compatibility
- const char* szAppend = pRootElement->Attribute("append");
- if ((szAppend && stricmp(szAppend, "yes") == 0))
- iAction = 1;
- // action takes precedence if both attributes exist
- const char* szAction = pRootElement->Attribute("action");
- if (szAction)
- {
- iAction = 0; // overwrite
- if (stricmp(szAction, "append") == 0)
- iAction = 1; // append
- else if (stricmp(szAction, "prepend") == 0)
- iAction = 2; // prepend
- }
- if (iAction == 0)
- settings.clear();
- TiXmlNode* pRegExp = pRootElement->FirstChild("regexp");
- int i = 0;
- while (pRegExp)
+ TiXmlElement *pElement = pRootElement;
+ while (pElement)
{
- if (pRegExp->FirstChild())
+ int iAction = 0; // overwrite
+ // for backward compatibility
+ const char* szAppend = pElement->Attribute("append");
+ if ((szAppend && stricmp(szAppend, "yes") == 0))
+ iAction = 1;
+ // action takes precedence if both attributes exist
+ const char* szAction = pElement->Attribute("action");
+ if (szAction)
+ {
+ iAction = 0; // overwrite
+ if (stricmp(szAction, "append") == 0)
+ iAction = 1; // append
+ else if (stricmp(szAction, "prepend") == 0)
+ iAction = 2; // prepend
+ }
+ if (iAction == 0)
+ settings.clear();
+ TiXmlNode* pRegExp = pElement->FirstChild("regexp");
+ int i = 0;
+ while (pRegExp)
{
- bool bByDate = false;
- int iDefaultSeason = 1;
- if (pRegExp->ToElement())
+ if (pRegExp->FirstChild())
{
- CStdString byDate = pRegExp->ToElement()->Attribute("bydate");
- if(byDate && stricmp(byDate, "true") == 0)
+ bool bByDate = false;
+ int iDefaultSeason = 1;
+ if (pRegExp->ToElement())
{
- bByDate = true;
- }
- CStdString defaultSeason = pRegExp->ToElement()->Attribute("defaultseason");
- if(!defaultSeason.empty())
- {
- iDefaultSeason = atoi(defaultSeason.c_str());
+ CStdString byDate = pRegExp->ToElement()->Attribute("bydate");
+ if(byDate && stricmp(byDate, "true") == 0)
+ {
+ bByDate = true;
+ }
+ CStdString defaultSeason = pRegExp->ToElement()->Attribute("defaultseason");
+ if(!defaultSeason.empty())
+ {
+ iDefaultSeason = atoi(defaultSeason.c_str());
+ }
}
+ CStdString regExp = pRegExp->FirstChild()->Value();
+ regExp.MakeLower();
+ if (iAction == 2)
+ settings.insert(settings.begin() + i++, 1, TVShowRegexp(bByDate,regExp,iDefaultSeason));
+ else
+ settings.push_back(TVShowRegexp(bByDate,regExp,iDefaultSeason));
}
- CStdString regExp = pRegExp->FirstChild()->Value();
- regExp.MakeLower();
- if (iAction == 2)
- settings.insert(settings.begin() + i++, 1, TVShowRegexp(bByDate,regExp,iDefaultSeason));
- else
- settings.push_back(TVShowRegexp(bByDate,regExp,iDefaultSeason));
+ pRegExp = pRegExp->NextSibling("regexp");
}
- pRegExp = pRegExp->NextSibling("regexp");
+
+ pElement = pElement->NextSiblingElement(pRootElement->Value());
}
}

0 comments on commit 79056b7

Please sign in to comment.
Something went wrong with that request. Please try again.