Don't search recursively for backgrounds. Recursing picks up backgrounds from group-specific dirs when it shouldn't.
This commit is contained in:
@@ -178,55 +178,64 @@ void BackgroundUtil::GetGlobalRandomMovies( const Song *pSong, const CString &sM
|
|||||||
vsPathsOut.clear();
|
vsPathsOut.clear();
|
||||||
vsNamesOut.clear();
|
vsNamesOut.clear();
|
||||||
|
|
||||||
set<CString> ssFilterToFileNames;
|
// Check for an exact match
|
||||||
if( pSong && !pSong->m_sGenre.empty() )
|
if( !sMatch.empty() )
|
||||||
GetFilterToFileNames( RANDOMMOVIES_DIR, pSong, ssFilterToFileNames );
|
|
||||||
|
|
||||||
vector<CString> vsDirsToTry;
|
|
||||||
if( pSong )
|
|
||||||
{
|
{
|
||||||
ASSERT( !pSong->m_sGroupName.empty() );
|
GetDirListing( RANDOMMOVIES_DIR+sMatch, vsPathsOut, false, true );
|
||||||
vsDirsToTry.push_back( RANDOMMOVIES_DIR+pSong->m_sGroupName+"/" );
|
if( !vsPathsOut.empty() )
|
||||||
}
|
goto found_files;
|
||||||
vsDirsToTry.push_back( RANDOMMOVIES_DIR );
|
|
||||||
|
|
||||||
FOREACH_CONST( CString, vsDirsToTry, sDir )
|
|
||||||
{
|
|
||||||
if( sMatch.empty() )
|
|
||||||
{
|
|
||||||
GetDirListingRecursive( *sDir, "*.avi", vsPathsOut );
|
|
||||||
GetDirListingRecursive( *sDir, "*.mpg", vsPathsOut );
|
|
||||||
GetDirListingRecursive( *sDir, "*.mpeg", vsPathsOut );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
LOG->Warn( "Background missing: %s", sMatch.c_str() );
|
||||||
GetDirListing( RANDOMMOVIES_DIR+sMatch, vsPathsOut, false, true );
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if( !ssFilterToFileNames.empty() )
|
//
|
||||||
|
// Search for the most appropriate background
|
||||||
|
//
|
||||||
|
{
|
||||||
|
set<CString> ssFilterToFileNames;
|
||||||
|
if( pSong && !pSong->m_sGenre.empty() )
|
||||||
|
GetFilterToFileNames( RANDOMMOVIES_DIR, pSong, ssFilterToFileNames );
|
||||||
|
|
||||||
|
vector<CString> vsDirsToTry;
|
||||||
|
if( pSong )
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<vsPathsOut.size(); i++ )
|
ASSERT( !pSong->m_sGroupName.empty() );
|
||||||
|
vsDirsToTry.push_back( RANDOMMOVIES_DIR+pSong->m_sGroupName+"/" );
|
||||||
|
}
|
||||||
|
vsDirsToTry.push_back( RANDOMMOVIES_DIR );
|
||||||
|
|
||||||
|
FOREACH_CONST( CString, vsDirsToTry, sDir )
|
||||||
|
{
|
||||||
|
GetDirListing( *sDir+"*.avi", vsPathsOut, false, true );
|
||||||
|
GetDirListing( *sDir+"*.mpg", vsPathsOut, false, true );
|
||||||
|
GetDirListing( *sDir+"*.mpeg", vsPathsOut, false, true );
|
||||||
|
|
||||||
|
if( !ssFilterToFileNames.empty() )
|
||||||
{
|
{
|
||||||
CString sBasename = Basename( vsPathsOut[i] );
|
for( unsigned i=0; i<vsPathsOut.size(); i++ )
|
||||||
bool bFound = ssFilterToFileNames.find(sBasename) != ssFilterToFileNames.end();
|
|
||||||
if( !bFound )
|
|
||||||
{
|
{
|
||||||
vsPathsOut.erase( vsPathsOut.begin()+i );
|
CString sBasename = Basename( vsPathsOut[i] );
|
||||||
i--;
|
bool bFound = ssFilterToFileNames.find(sBasename) != ssFilterToFileNames.end();
|
||||||
|
if( !bFound )
|
||||||
|
{
|
||||||
|
vsPathsOut.erase( vsPathsOut.begin()+i );
|
||||||
|
i--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FOREACH_CONST( CString, vsPathsOut, s )
|
if( !vsPathsOut.empty() )
|
||||||
{
|
goto found_files;
|
||||||
CString sName = s->Right( s->size() - RANDOMMOVIES_DIR.size() - 1 );
|
|
||||||
vsNamesOut.push_back( sName );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !vsPathsOut.empty() )
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found_files:
|
||||||
|
|
||||||
|
FOREACH_CONST( CString, vsPathsOut, s )
|
||||||
|
{
|
||||||
|
CString sName = s->Right( s->size() - RANDOMMOVIES_DIR.size() - 1 );
|
||||||
|
vsNamesOut.push_back( sName );
|
||||||
|
}
|
||||||
StripCvs( vsPathsOut, vsNamesOut );
|
StripCvs( vsPathsOut, vsNamesOut );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user