Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #2568 from night199uk/cosmetics

[musicdb] Cosmetics from the original MusicBrainz patch
  • Loading branch information...
commit 17411f251ab7695659e1bf560551f1acb5eaf94e 2 parents d1d4334 + 84506df
@night199uk night199uk authored
View
35 xbmc/music/MusicDatabase.cpp
@@ -166,7 +166,7 @@ bool CMusicDatabase::CreateTables()
CLog::Log(LOGINFO, "create song index3");
m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
CLog::Log(LOGINFO, "create song index6");
- m_pDS->exec("CREATE INDEX idxSong6 ON song(idPath)");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSong6 ON song( idPath, strFileName(255) )");
CLog::Log(LOGINFO, "create song_artist indexes");
m_pDS->exec("CREATE UNIQUE INDEX idxSongArtist_1 ON song_artist ( idSong, idArtist )\n");
@@ -1310,16 +1310,7 @@ bool CMusicDatabase::GetArtistInfo(int idArtist, CArtist &info, bool needAll)
if (idArtist == -1)
return false; // not in the database
- CStdString strSQL=PrepareSQL("SELECT artist.idArtist AS idArtist, strArtist, "
- " strBorn, strFormed, strGenres,"
- " strMoods, strStyles, strInstruments, "
- " strBiography, strDied, strDisbanded, "
- " strYearsActive, strImage, strFanart "
- " FROM artist "
- " JOIN artistinfo "
- " ON artist.idArtist = artistinfo.idArtist "
- " WHERE artistinfo.idArtist = %i"
- , idArtist);
+ CStdString strSQL=PrepareSQL("SELECT * FROM artistview WHERE idArtist = %i", idArtist);
if (!m_pDS2->query(strSQL.c_str())) return false;
int iRowsFound = m_pDS2->num_rows();
@@ -1350,6 +1341,11 @@ bool CMusicDatabase::GetArtistInfo(int idArtist, CArtist &info, bool needAll)
return false;
}
+bool CMusicDatabase::HasArtistInfo(int idArtist)
+{
+ return strtol(GetSingleValue("artistinfo", "count(idArtist)", PrepareSQL("idArtist = %ld", idArtist)), NULL, 10) > 0;
+}
+
bool CMusicDatabase::DeleteArtistInfo(int idArtist)
{
if (idArtist == -1)
@@ -1682,7 +1678,7 @@ void CMusicDatabase::IncrementPlayCount(const CFileItem& item)
}
}
-bool CMusicDatabase::GetSongsByPath(const CStdString& strPath1, CSongMap& songs, bool bAppendToMap)
+bool CMusicDatabase::GetSongsByPath(const CStdString& strPath1, MAPSONGS& songs, bool bAppendToMap)
{
CStdString strPath(strPath1);
try
@@ -1691,7 +1687,7 @@ bool CMusicDatabase::GetSongsByPath(const CStdString& strPath1, CSongMap& songs,
URIUtils::AddSlashAtEnd(strPath);
if (!bAppendToMap)
- songs.Clear();
+ songs.clear();
if (NULL == m_pDB.get()) return false;
if (NULL == m_pDS.get()) return false;
@@ -1707,7 +1703,7 @@ bool CMusicDatabase::GetSongsByPath(const CStdString& strPath1, CSongMap& songs,
while (!m_pDS->eof())
{
CSong song = GetSongFromDataset();
- songs.Add(song.strFileName, song);
+ songs.insert(make_pair(song.strFileName, song));
m_pDS->next();
}
@@ -3721,6 +3717,11 @@ bool CMusicDatabase::UpdateOldVersion(int version)
m_pDS->exec(PrepareSQL("UPDATE song SET strFileName='%s' WHERE idSong=%d", filename.c_str(), i->first));
}
}
+ if (version < 33)
+ {
+ m_pDS->exec("DROP INDEX idxSong6 ON song");
+ m_pDS->exec("CREATE UNIQUE INDEX idxSong6 on song( idPath, strFileName(255) )");
+ }
// always recreate the views after any table change
CreateViews();
@@ -3729,7 +3730,7 @@ bool CMusicDatabase::UpdateOldVersion(int version)
int CMusicDatabase::GetMinVersion() const
{
- return 32;
+ return 33;
}
unsigned int CMusicDatabase::GetSongIDs(const Filter &filter, vector<pair<int,int> > &songIDs)
@@ -4132,7 +4133,7 @@ bool CMusicDatabase::GetPathHash(const CStdString &path, CStdString &hash)
return false;
}
-bool CMusicDatabase::RemoveSongsFromPath(const CStdString &path1, CSongMap &songs, bool exact)
+bool CMusicDatabase::RemoveSongsFromPath(const CStdString &path1, MAPSONGS& songs, bool exact)
{
// We need to remove all songs from this path, as their tags are going
// to be re-read. We need to remove all songs from the song table + all links to them
@@ -4185,7 +4186,7 @@ bool CMusicDatabase::RemoveSongsFromPath(const CStdString &path1, CSongMap &song
{
CSong song = GetSongFromDataset();
song.strThumb = GetArtForItem(song.idSong, "song", "thumb");
- songs.Add(song.strFileName, song);
+ songs.insert(make_pair(song.strFileName, song));
songIds += PrepareSQL("%i,", song.idSong);
ids.push_back(song.idSong);
m_pDS->next();
View
10 xbmc/music/MusicDatabase.h
@@ -117,12 +117,18 @@ class CMusicDatabase : public CDatabase
bool GetAlbumInfo(int idAlbum, CAlbum &info, VECSONGS* songs, bool scrapedInfo = false);
bool HasAlbumInfo(int idAlbum);
bool GetArtistInfo(int idArtist, CArtist &info, bool needAll=true);
+
+ /*! \brief Check if an artist entity has additional metadata (scraped)
+ \param idArtist the id of the Artist to check
+ \return true or false - whether the artist has metadata
+ */
+ bool HasArtistInfo(int idArtist);
bool GetSongByFileName(const CStdString& strFileName, CSong& song, int startOffset = 0);
int GetAlbumIdByPath(const CStdString& path);
bool GetSongById(int idSong, CSong& song);
bool GetSongByKaraokeNumber( int number, CSong& song );
bool SetKaraokeSongDelay( int idSong, int delay );
- bool GetSongsByPath(const CStdString& strPath, CSongMap& songs, bool bAppendToMap = false);
+ bool GetSongsByPath(const CStdString& strPath, MAPSONGS& songs, bool bAppendToMap = false);
bool Search(const CStdString& search, CFileItemList &items);
bool GetAlbumFromSong(int idSong, CAlbum &album);
@@ -148,7 +154,7 @@ class CMusicDatabase : public CDatabase
\param item CFileItem to increment the playcount for
*/
void IncrementPlayCount(const CFileItem &item);
- bool RemoveSongsFromPath(const CStdString &path, CSongMap &songs, bool exact=true);
+ bool RemoveSongsFromPath(const CStdString &path, MAPSONGS& songs, bool exact=true);
bool CleanupOrphanedItems();
bool GetPaths(std::set<CStdString> &paths);
bool SetPathHash(const CStdString &path, const CStdString &hash);
View
13 xbmc/music/MusicInfoLoader.cpp
@@ -154,13 +154,12 @@ bool CMusicInfoLoader::LoadItem(CFileItem* pItem)
m_databaseHits++;
}
- CSong *song=NULL;
-
- if ((song=m_songsMap.Find(pItem->GetPath()))!=NULL)
+ MAPSONGS::iterator it = m_songsMap.find(pItem->GetPath());
+ if (it != m_songsMap.end())
{ // Have we loaded this item from database before
- pItem->GetMusicInfoTag()->SetSong(*song);
- if (!song->strThumb.empty())
- pItem->SetArt("thumb", song->strThumb);
+ pItem->GetMusicInfoTag()->SetSong(it->second);
+ if (!it->second.strThumb.empty())
+ pItem->SetArt("thumb", it->second.strThumb);
}
else if (pItem->IsMusicDb())
{ // a music db item that doesn't have tag loaded - grab details from the database
@@ -198,7 +197,7 @@ bool CMusicInfoLoader::LoadItem(CFileItem* pItem)
void CMusicInfoLoader::OnLoaderFinish()
{
// cleanup last loaded songs from database
- m_songsMap.Clear();
+ m_songsMap.clear();
// cleanup cache loaded from HD
m_mapFileItems->Clear();
View
2  xbmc/music/MusicInfoLoader.h
@@ -44,7 +44,7 @@ class CMusicInfoLoader : public CBackgroundInfoLoader
protected:
CStdString m_strCacheFileName;
CFileItemList* m_mapFileItems;
- CSongMap m_songsMap;
+ MAPSONGS m_songsMap;
CStdString m_strPrevPath;
CMusicDatabase m_musicDatabase;
unsigned int m_databaseHits;
View
42 xbmc/music/Song.cpp
@@ -130,45 +130,3 @@ bool CSong::ArtMatches(const CSong &right) const
return (right.strThumb == strThumb &&
embeddedArt.matches(right.embeddedArt));
}
-
-CSongMap::CSongMap()
-{
-}
-
-std::map<CStdString, CSong>::const_iterator CSongMap::Begin()
-{
- return m_map.begin();
-}
-
-std::map<CStdString, CSong>::const_iterator CSongMap::End()
-{
- return m_map.end();
-}
-
-void CSongMap::Add(const CStdString &file, const CSong &song)
-{
- CStdString lower = file;
- lower.ToLower();
- m_map.insert(pair<CStdString, CSong>(lower, song));
-}
-
-CSong* CSongMap::Find(const CStdString &file)
-{
- CStdString lower = file;
- lower.ToLower();
- map<CStdString, CSong>::iterator it = m_map.find(lower);
- if (it == m_map.end())
- return NULL;
- return &(*it).second;
-}
-
-void CSongMap::Clear()
-{
- m_map.erase(m_map.begin(), m_map.end());
-}
-
-int CSongMap::Size()
-{
- return (int)m_map.size();
-}
-
View
16 xbmc/music/Song.h
@@ -113,21 +113,7 @@ class CSong: public ISerializable
\ingroup music
\brief A map of CSong objects, used for CMusicDatabase
*/
-class CSongMap
-{
-public:
- CSongMap();
-
- std::map<CStdString, CSong>::const_iterator Begin();
- std::map<CStdString, CSong>::const_iterator End();
- CSong *Find(const CStdString &file);
- void Add(const CStdString &file, const CSong &song);
- void Clear();
- int Size();
-
-private:
- std::map<CStdString, CSong> m_map;
-};
+typedef std::map<std::string, CSong> MAPSONGS;
/*!
\ingroup music
View
182 xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -458,27 +458,17 @@ bool CMusicInfoScanner::DoScan(const CStdString& strDirectory)
return !m_bStop;
}
-int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString& strDirectory)
+INFO_RET CMusicInfoScanner::ScanTags(const CFileItemList& items, CFileItemList& scannedItems)
{
- CSongMap songsMap;
-
- // get all information for all files in current directory from database, and remove them
- if (m_musicDatabase.RemoveSongsFromPath(strDirectory, songsMap))
- m_needsCleanup = true;
-
- VECSONGS songsToAdd;
-
CStdStringArray regexps = g_advancedSettings.m_audioExcludeFromScanRegExps;
// for every file found, but skip folder
for (int i = 0; i < items.Size(); ++i)
{
CFileItemPtr pItem = items[i];
- CStdString strExtension;
- URIUtils::GetExtension(pItem->GetPath(), strExtension);
if (m_bStop)
- return 0;
+ return INFO_CANCELLED;
// Discard all excluded files defined by m_musicExcludeRegExps
if (CUtil::ExcludeFileOrFolder(pItem->GetPath(), regexps))
@@ -488,14 +478,11 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
if (!pItem->m_bIsFolder && !pItem->IsPlayList() && !pItem->IsPicture() && !pItem->IsLyrics() )
{
m_currentItem++;
-// CLog::Log(LOGDEBUG, "%s - Reading tag for: %s", __FUNCTION__, pItem->GetPath().c_str());
-
- // grab info from the song
- CSong *dbSong = songsMap.Find(pItem->GetPath());
CMusicInfoTag& tag = *pItem->GetMusicInfoTag();
- if (!tag.Loaded() )
- { // read the tag from a file
+ if (!tag.Loaded())
+ {
+ // read the tag from a file
auto_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(pItem->GetPath()));
if (NULL != pLoader.get())
pLoader->Load(pItem->GetPath(), tag);
@@ -507,43 +494,67 @@ int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString&
m_handle->SetPercentage(m_currentItem/(float)m_itemCount*100);
if (tag.Loaded())
- {
- CSong song(tag);
+ scannedItems.Add(pItem);
+ else
+ CLog::Log(LOGDEBUG, "%s - No tag found for: %s", __FUNCTION__, pItem->GetPath().c_str());
+ }
+ }
+ return INFO_ADDED;
+}
- // ensure our song has a valid filename or else it will assert in AddSong()
- if (song.strFileName.IsEmpty())
- {
- // copy filename from path in case UPnP or other tag loaders didn't specify one (FIXME?)
- song.strFileName = pItem->GetPath();
+int CMusicInfoScanner::RetrieveMusicInfo(CFileItemList& items, const CStdString& strDirectory)
+{
+ MAPSONGS songsMap;
- // if we still don't have a valid filename, skip the song
- if (song.strFileName.IsEmpty())
- {
- // this shouldn't ideally happen!
- CLog::Log(LOGERROR, "Skipping song since it doesn't seem to have a filename");
- continue;
- }
- }
+ // get all information for all files in current directory from database, and remove them
+ if (m_musicDatabase.RemoveSongsFromPath(strDirectory, songsMap))
+ m_needsCleanup = true;
- song.iStartOffset = pItem->m_lStartOffset;
- song.iEndOffset = pItem->m_lEndOffset;
- song.strThumb = pItem->GetUserMusicThumb(true);
- if (dbSong)
- { // keep the db-only fields intact on rescan...
- song.iTimesPlayed = dbSong->iTimesPlayed;
- song.lastPlayed = dbSong->lastPlayed;
- song.iKaraokeNumber = dbSong->iKaraokeNumber;
-
- if (song.rating == '0') song.rating = dbSong->rating;
- if (song.strThumb.empty())
- song.strThumb = dbSong->strThumb;
- }
- songsToAdd.push_back(song);
-// CLog::Log(LOGDEBUG, "%s - Tag loaded for: %s", __FUNCTION__, pItem->GetPath().c_str());
+ CFileItemList scannedItems;
+ if (ScanTags(items, scannedItems) == INFO_CANCELLED)
+ return 0;
+
+ VECSONGS songsToAdd;
+ for (int i = 0; i < scannedItems.Size(); ++i)
+ {
+ CFileItemPtr pItem = scannedItems[i];
+ CMusicInfoTag& tag = *pItem->GetMusicInfoTag();
+ CSong song(tag);
+
+ // ensure our song has a valid filename or else it will assert in AddSong()
+ if (song.strFileName.IsEmpty())
+ {
+ // copy filename from path in case UPnP or other tag loaders didn't specify one (FIXME?)
+ song.strFileName = pItem->GetPath();
+
+ // if we still don't have a valid filename, skip the song
+ if (song.strFileName.IsEmpty())
+ {
+ // this shouldn't ideally happen!
+ CLog::Log(LOGERROR, "Skipping song since it doesn't seem to have a filename");
+ continue;
}
- else
- CLog::Log(LOGDEBUG, "%s - No tag found for: %s", __FUNCTION__, pItem->GetPath().c_str());
}
+
+ song.iStartOffset = pItem->m_lStartOffset;
+ song.iEndOffset = pItem->m_lEndOffset;
+ song.strThumb = pItem->GetUserMusicThumb(true);
+
+ // grab info from the song
+ MAPSONGS::iterator it = songsMap.find(pItem->GetPath());
+ if (it != songsMap.end())
+ {
+ // keep the db-only fields intact on rescan...
+ song.iTimesPlayed = it->second.iTimesPlayed;
+ song.lastPlayed = it->second.lastPlayed;
+ song.iKaraokeNumber = it->second.iKaraokeNumber;
+
+ if (song.rating == '0')
+ song.rating = it->second.rating;
+ if (song.strThumb.empty())
+ song.strThumb = it->second.strThumb;
+ }
+ songsToAdd.push_back(song);
}
VECALBUMS albums;
@@ -996,14 +1007,13 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
}
}
- CGUIDialogSelect *pDlg=NULL;
+ CGUIDialogSelect *pDlg = NULL;
int iSelectedAlbum=0;
if (result == CNfoFile::NO_NFO)
{
iSelectedAlbum = -1; // set negative so that we can detect a failure
if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1)
{
- int bestMatch = -1;
double bestRelevance = 0;
double minRelevance = THRESHOLD;
if (scraper.GetAlbumCount() > 1) // score the matches
@@ -1029,7 +1039,7 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
if (relevance >= max(minRelevance, bestRelevance))
{ // we auto-select the best of these
bestRelevance = relevance;
- bestMatch = i;
+ iSelectedAlbum = i;
}
if (pDialog)
{
@@ -1043,6 +1053,35 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
if (relevance > .99f) // we're so close, no reason to search further
break;
}
+
+ if (pDialog && bestRelevance < THRESHOLD)
+ {
+ pDlg->Sort(false);
+ pDlg->DoModal();
+
+ // and wait till user selects one
+ if (pDlg->GetSelectedLabel() < 0)
+ { // none chosen
+ if (!pDlg->IsButtonPressed())
+ return false;
+
+ // manual button pressed
+ CStdString strNewAlbum = album.strAlbum;
+ if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return false;
+ if (strNewAlbum == "") return false;
+
+ CStdString strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator);
+ if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
+
+ pDialog->SetLine(0, strNewAlbum);
+ pDialog->SetLine(1, strNewArtist);
+ pDialog->Progress();
+
+ m_musicDatabase.Close();
+ return DownloadAlbumInfo(strPath,strNewArtist,strNewAlbum,bCanceled,albumInfo,pDialog);
+ }
+ iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth;
+ }
}
else
{
@@ -1055,40 +1094,7 @@ bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdS
m_musicDatabase.Close();
return false;
}
- bestRelevance = relevance;
- bestMatch = 0;
- }
-
- iSelectedAlbum = bestMatch;
- if (pDialog && bestRelevance < THRESHOLD)
- {
- pDlg->Sort(false);
- pDlg->DoModal();
-
- // and wait till user selects one
- if (pDlg->GetSelectedLabel() < 0)
- { // none chosen
- if (!pDlg->IsButtonPressed())
- {
- bCanceled = true;
- return false;
- }
- // manual button pressed
- CStdString strNewAlbum = strAlbum;
- if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return false;
- if (strNewAlbum == "") return false;
-
- CStdString strNewArtist = strArtist;
- if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false;
-
- pDialog->SetLine(0, strNewAlbum);
- pDialog->SetLine(1, strNewArtist);
- pDialog->Progress();
-
- m_musicDatabase.Close();
- return DownloadAlbumInfo(strPath,strNewArtist,strNewAlbum,bCanceled,albumInfo,pDialog);
- }
- iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth;
+ iSelectedAlbum = 0;
}
}
@@ -1153,7 +1159,7 @@ bool CMusicInfoScanner::DownloadArtistInfo(const CStdString& strPath, const CStd
bCanceled = false;
CArtist artist;
m_musicDatabase.Open();
- if (m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info
+ if (m_musicDatabase.HasArtistInfo(params.GetArtistId()) && m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info
return true;
// find artist info
View
21 xbmc/music/infoscanner/MusicInfoScanner.h
@@ -28,6 +28,18 @@ class CGUIDialogProgressBarHandle;
namespace MUSIC_INFO
{
+/*! \brief return values from the information lookup functions
+ */
+enum INFO_RET
+{
+ INFO_CANCELLED,
+ INFO_ERROR,
+ INFO_NOT_NEEDED,
+ INFO_HAVE_ALREADY,
+ INFO_NOT_FOUND,
+ INFO_ADDED
+};
+
class CMusicInfoScanner : CThread, public IRunnable
{
public:
@@ -97,6 +109,15 @@ class CMusicInfoScanner : CThread, public IRunnable
protected:
virtual void Process();
int RetrieveMusicInfo(CFileItemList& items, const CStdString& strDirectory);
+
+ /*! \brief Scan in the ID3/Ogg/FLAC tags for a bunch of FileItems
+ Given a list of FileItems, scan in the tags for those FileItems
+ and populate a new FileItemList with the files that were successfully scanned.
+ Any files which couldn't be scanned (no/bad tags) are discarded in the process.
+ \param items [in] list of FileItems to scan
+ \param scannedItems [in] list to populate with the scannedItems
+ */
+ INFO_RET ScanTags(const CFileItemList& items, CFileItemList& scannedItems);
int GetPathHash(const CFileItemList &items, CStdString &hash);
void GetAlbumArtwork(long id, const CAlbum &artist);
View
213 xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -323,14 +323,11 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);
if (params.GetAlbumId() == -1)
{ // artist lookup
- artist.idArtist = params.GetArtistId();
- artist.strArtist = StringUtils::Join(pItem->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator);
+ m_musicdatabase.GetArtistInfo(params.GetArtistId(), artist);
}
else
{ // album lookup
- album.idAlbum = params.GetAlbumId();
- album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum();
- album.artist = pItem->GetMusicInfoTag()->GetArtist();
+ m_musicdatabase.GetAlbumInfo(params.GetAlbumId(), album, NULL);
// we're going to need it's path as well (we assume that there's only one) - this is for
// assigning thumbs to folders, and obtaining the local folder.jpg
@@ -392,9 +389,9 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
}
if (album.idAlbum == -1 && foundAlbum == false)
- ShowArtistInfo(artist, pItem->GetPath(), false, bShowInfo);
+ ShowArtistInfo(artist, pItem->GetPath(), bShowInfo);
else
- ShowAlbumInfo(album, strPath, false, bShowInfo);
+ ShowAlbumInfo(album, strPath, bShowInfo);
m_musicdatabase.Close();
}
@@ -412,183 +409,115 @@ void CGUIWindowMusicBase::OnManualAlbumInfo()
ShowAlbumInfo(album,"",true);
}
-void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bRefresh, bool bShowInfo)
+void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bShowInfo /* = true */)
{
bool saveDb = artist.idArtist != -1;
if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
saveDb = false;
- // check cache
- CArtist artistInfo;
- if (!bRefresh && m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo))
+ CMusicArtistInfo artistInfo;
+ while (1)
{
- if (!bShowInfo)
- return;
-
- CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
- if (pDlgArtistInfo)
+ if (!m_musicdatabase.HasArtistInfo(artist.idArtist) ||
+ !m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo.GetArtist()))
{
- pDlgArtistInfo->SetArtist(artistInfo, path);
+ if (g_application.IsMusicScanning())
+ {
+ CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
+ break;
+ }
- if (bShowInfo)
- pDlgArtistInfo->DoModal();
+ if (!FindArtistInfo(artist.strArtist, artistInfo, bShowInfo ? SELECTION_ALLOWED : SELECTION_AUTO))
+ break;
- if (!pDlgArtistInfo->NeedRefresh())
+ if (!artistInfo.Loaded())
{
- if (pDlgArtistInfo->HasUpdatedThumb())
- Refresh();
-
- return;
+ // Failed to download album info
+ CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0);
+ break;
}
- bRefresh = true;
- m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist);
- }
- }
- // If we are scanning for music info in the background,
- // other writing access to the database is prohibited.
- if (g_application.IsMusicScanning())
- {
- CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
- return;
- }
+ if (saveDb)
+ m_musicdatabase.SetArtistInfo(artist.idArtist, artistInfo.GetArtist());
+ }
- CMusicArtistInfo info;
- if (FindArtistInfo(artist.strArtist, info, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO))
- {
- // download the album info
- if ( info.Loaded() )
+ CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
+ if (pDlgArtistInfo)
{
- if (saveDb)
- {
- // save to database
- m_musicdatabase.SetArtistInfo(artist.idArtist, info.GetArtist());
- }
- if (m_dlgProgress && bShowInfo)
- m_dlgProgress->Close();
+ pDlgArtistInfo->SetArtist(artistInfo.GetArtist(), path);
+ pDlgArtistInfo->DoModal();
- // ok, show album info
- CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
- if (pDlgArtistInfo)
+ if (pDlgArtistInfo->NeedRefresh())
{
- pDlgArtistInfo->SetArtist(info.GetArtist(), path);
- if (bShowInfo)
- pDlgArtistInfo->DoModal();
-
- CArtist artistInfo = info.GetArtist();
- artistInfo.idArtist = artist.idArtist;
-/*
- if (pDlgAlbumInfo->HasUpdatedThumb())
- UpdateThumb(artistInfo, path);
-*/
- // just update for now
- Refresh();
- if (pDlgArtistInfo->NeedRefresh())
- {
- m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist);
- ShowArtistInfo(artist, path, true, bShowInfo);
- return;
- }
+ m_musicdatabase.DeleteArtistInfo(artist.idArtist);
+ continue;
+ }
+ else if (pDlgArtistInfo->HasUpdatedThumb())
+ {
+ Update(m_vecItems->GetPath());
}
}
- else
- {
- // failed 2 download album info
- CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0);
- }
+ break;
}
-
- if (m_dlgProgress && bShowInfo)
+ if (m_dlgProgress)
m_dlgProgress->Close();
}
-void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bRefresh, bool bShowInfo)
+void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bShowInfo /* = true */)
{
bool saveDb = album.idAlbum != -1;
if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
saveDb = false;
- // check cache
- CAlbum albumInfo;
- if (!bRefresh && m_musicdatabase.GetAlbumInfo(album.idAlbum, albumInfo, &albumInfo.songs))
+ CMusicAlbumInfo albumInfo;
+ while (1)
{
- if (!bShowInfo)
- return;
-
- CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
- if (pDlgAlbumInfo)
+ if (!m_musicdatabase.HasAlbumInfo(album.idAlbum) ||
+ !m_musicdatabase.GetAlbumInfo(album.idAlbum, albumInfo.GetAlbum(), &albumInfo.GetAlbum().songs))
{
- pDlgAlbumInfo->SetAlbum(albumInfo, path);
- if (bShowInfo)
- pDlgAlbumInfo->DoModal();
+ if (g_application.IsMusicScanning())
+ {
+ CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
+ break;
+ }
- if (!pDlgAlbumInfo->NeedRefresh())
+ if (!FindAlbumInfo(album.strAlbum,
+ StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator),
+ albumInfo,
+ bShowInfo ? SELECTION_ALLOWED : SELECTION_AUTO))
+ break;
+
+ if (!albumInfo.Loaded())
{
- if (pDlgAlbumInfo->HasUpdatedThumb())
- UpdateThumb(albumInfo, path);
- return;
+ CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
+ break;
}
- bRefresh = true;
- m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum);
- }
- }
- // If we are scanning for music info in the background,
- // other writing access to the database is prohibited.
- if (g_application.IsMusicScanning())
- {
- CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
- return;
- }
+ albumInfo.GetAlbum().strAlbum = album.strAlbum;
- CMusicAlbumInfo info;
- if (FindAlbumInfo(album.strAlbum, StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator), info, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO))
- {
- // download the album info
- if ( info.Loaded() )
+ if (saveDb)
+ m_musicdatabase.SetAlbumInfo(album.idAlbum, albumInfo.GetAlbum(), albumInfo.GetSongs());
+ }
+
+ CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
+ if (pDlgAlbumInfo)
{
- // set album title from musicinfotag, not the one we got from allmusic.com
- info.SetTitle(album.strAlbum);
+ pDlgAlbumInfo->SetAlbum(albumInfo.GetAlbum(), path);
+ pDlgAlbumInfo->DoModal();
- if (saveDb)
+ if (pDlgAlbumInfo->NeedRefresh())
{
- // save to database
- m_musicdatabase.SetAlbumInfo(album.idAlbum, info.GetAlbum(), info.GetSongs());
+ m_musicdatabase.DeleteAlbumInfo(album.idAlbum);
+ continue;
}
- if (m_dlgProgress && bShowInfo)
- m_dlgProgress->Close();
-
- UpdateThumb(album, path);
-
- // ok, show album info
- CGUIDialogMusicInfo *pDlgAlbumInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO);
- if (pDlgAlbumInfo)
+ else if (pDlgAlbumInfo->HasUpdatedThumb())
{
- pDlgAlbumInfo->SetAlbum(info.GetAlbum(), path);
- if (bShowInfo)
- pDlgAlbumInfo->DoModal();
-
- CAlbum albumInfo = info.GetAlbum();
- albumInfo.idAlbum = album.idAlbum;
- if (pDlgAlbumInfo->HasUpdatedThumb())
- UpdateThumb(albumInfo, path);
-
- if (pDlgAlbumInfo->NeedRefresh())
- {
- m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum);
- ShowAlbumInfo(album, path, true, bShowInfo);
- return;
- }
+ UpdateThumb(album, path);
}
}
- else
- {
- // failed 2 download album info
- CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
- }
+ break;
}
-
- if (m_dlgProgress && bShowInfo)
+ if (m_dlgProgress)
m_dlgProgress->Close();
}
View
4 xbmc/music/windows/GUIWindowMusicBase.h
@@ -88,8 +88,8 @@ class CGUIWindowMusicBase : public CGUIMediaWindow
bool FindAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist, MUSIC_GRABBER::CMusicAlbumInfo& album, ALLOW_SELECTION allowSelection);
bool FindArtistInfo(const CStdString& strArtist, MUSIC_GRABBER::CMusicArtistInfo& artist, ALLOW_SELECTION allowSelection);
- void ShowAlbumInfo(const CAlbum &album, const CStdString &strPath, bool bRefresh, bool bShowInfo = true);
- void ShowArtistInfo(const CArtist &artist, const CStdString &strPath, bool bRefresh, bool bShowInfo = true);
+ void ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bShowInfo = true);
+ void ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bShowInfo = true);
void ShowSongInfo(CFileItem* pItem);
void UpdateThumb(const CAlbum &album, const CStdString &path);
View
2  xbmc/music/windows/GUIWindowMusicSongs.cpp
@@ -483,7 +483,7 @@ void CGUIWindowMusicSongs::OnRemoveSource(int iItem)
bool bCanceled;
if (CGUIDialogYesNo::ShowAndGetInput(522,20340,20341,20022,bCanceled))
{
- CSongMap songs;
+ MAPSONGS songs;
CMusicDatabase database;
database.Open();
database.RemoveSongsFromPath(m_vecItems->Get(iItem)->GetPath(),songs,false);
Please sign in to comment.
Something went wrong with that request. Please try again.