cpp help please
Posted: Thu Sep 05, 2013 5:21 pm
I am attempting to update our music scrapers by dividing music into the appropriate categories, ie albums and artists (until this point one scraper was used for both...mainline uses one for each). So far I've made good progress splitting them but am stuck now.
Here's the original code for filling the scrapers properly (made for one music scraper)
It's a loop which I don't understand as I'm new to cpp, and wondering If the loop is necessary at this point since I've got music split up...here's what I've done which is only grabbing the album scraper and leaving the other scrapers f.u.b.a.r. (here's the diff of everything I've done)
Here's the specific code that I came up with which is clearly not working
I have a couple of other questions but will start here for now, tia for any help...
Here's the original code for filling the scrapers properly (made for one music scraper)
Code: Select all
void CGUIWindowSettingsCategory::FillInScrapers(CGUISpinControlEx *pControl, const CStdString& strSelected, const CStdString& strContent)
{
CFileItemList items;
if (strContent.Equals("music"))
CDirectory::GetDirectory("special://xbmc/system/scrapers/music",items,".xml",false);
else
CDirectory::GetDirectory("special://xbmc/system/scrapers/video",items,".xml",false);
int j=0;
int k=0;
pControl->Clear();
for ( int i=0;i<items.Size();++i)
{
if (items[i]->m_bIsFolder)
continue;
CScraperParser parser;
if (parser.Load(items[i]->GetPath()))
{
if (parser.GetContent() != strContent && !strContent.Equals("music"))
continue;
if (parser.GetName().Equals(strSelected) || URIUtils::GetFileName(items[i]->GetPath()).Equals(strSelected))
{
if (strContent.Equals("music")) // native strContent would be albums or artists but we're using the same scraper for both
{
if (g_guiSettings.GetString("musiclibrary.scraper") != strSelected)
{
g_guiSettings.SetString("musiclibrary.scraper", URIUtils::GetFileName(items[i]->GetPath()));
SScraperInfo info;
CMusicDatabase database;
info.strPath = g_guiSettings.GetString("musiclibrary.scraper");
info.strContent = "albums";
info.strTitle = parser.GetName();
database.Open();
database.SetScraperForPath("musicdb://",info);
database.Close();
}
}
else if (strContent.Equals("movies"))
g_guiSettings.SetString("scrapers.moviedefault", URIUtils::GetFileName(items[i]->GetPath()));
else if (strContent.Equals("tvshows"))
g_guiSettings.SetString("scrapers.tvshowdefault", URIUtils::GetFileName(items[i]->GetPath()));
else if (strContent.Equals("musicvideos"))
g_guiSettings.SetString("scrapers.musicvideodefault", URIUtils::GetFileName(items[i]->GetPath()));
k = j;
}
pControl->AddLabel(parser.GetName(),j++);
}
}
pControl->SetValue(k);
}
Here's the specific code that I came up with which is clearly not working
Code: Select all
void CGUIWindowSettingsCategory::FillInScrapers(CGUISpinControlEx *pControl, const CStdString& strSelected, const CStdString& strContent)
{
CFileItemList items;
if (strContent.Equals("albums"))
CDirectory::GetDirectory("special://xbmc/system/scrapers/music/albums",items,".xml",false);
else if (strContent.Equals("artists"))
CDirectory::GetDirectory("special://xbmc/system/scrapers/music/artists",items,".xml",false);
else
CDirectory::GetDirectory("special://xbmc/system/scrapers/video",items,".xml",false);
int j=0;
int k=0;
pControl->Clear();
for ( int i=0;i<items.Size();++i)
{
if (items[i]->m_bIsFolder)
continue;
CScraperParser parser;
if (parser.Load(items[i]->GetPath()))
{
if (strContent.Equals("albums"))
g_guiSettings.SetString("musiclibrary.albumscraper", URIUtils::GetFileName(items[i]->GetPath()));
else if (strContent.Equals("artists"))
g_guiSettings.SetString("musiclibrary.artistscraper", URIUtils::GetFileName(items[i]->GetPath()));
else if (strContent.Equals("movies"))
g_guiSettings.SetString("scrapers.moviedefault", URIUtils::GetFileName(items[i]->GetPath()));
else if (strContent.Equals("tvshows"))
g_guiSettings.SetString("scrapers.tvshowdefault", URIUtils::GetFileName(items[i]->GetPath()));
else if (strContent.Equals("musicvideos"))
g_guiSettings.SetString("scrapers.musicvideodefault", URIUtils::GetFileName(items[i]->GetPath()));
k = j;
}
pControl->AddLabel(parser.GetName(),j++);
}
pControl->SetValue(k);
}