aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarnova <arnova77@gmail.com>2013-06-26 06:04:29 -0700
committerarnova <arnova77@gmail.com>2013-06-26 06:04:29 -0700
commitec3589ef31952355113d514342e5ae399a3a7243 (patch)
tree21921bb49034aa426647225f73d30a4d2e541116
parentbc7b5631f019b217c2afb9ee2c26ac29e4203bcc (diff)
parent4026ea3e00e6322e80a123ff4c7fa6a45b51fe19 (diff)
Merge pull request #2906 from arnova/music_db_fixes
Music info/db (regression) fixes
-rw-r--r--xbmc/music/Album.cpp2
-rw-r--r--xbmc/music/MusicDatabase.cpp18
-rw-r--r--xbmc/music/infoscanner/MusicInfoScanner.cpp25
-rw-r--r--xbmc/music/windows/GUIWindowMusicBase.cpp26
-rw-r--r--xbmc/music/windows/GUIWindowMusicBase.h2
5 files changed, 48 insertions, 25 deletions
diff --git a/xbmc/music/Album.cpp b/xbmc/music/Album.cpp
index 266f06bf09..10c8b04b71 100644
--- a/xbmc/music/Album.cpp
+++ b/xbmc/music/Album.cpp
@@ -50,7 +50,7 @@ CStdString CAlbum::GetArtistString() const
CStdString CAlbum::GetGenreString() const
{
- return StringUtils::Join(artist, g_advancedSettings.m_musicItemSeparator);
+ return StringUtils::Join(genre, g_advancedSettings.m_musicItemSeparator);
}
bool CAlbum::operator<(const CAlbum &a) const
diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp
index fe793bccc5..19a9010369 100644
--- a/xbmc/music/MusicDatabase.cpp
+++ b/xbmc/music/MusicDatabase.cpp
@@ -440,13 +440,13 @@ int CMusicDatabase::AddSong(const int idAlbum,
return idSong;
}
- int CMusicDatabase::UpdateSong(int idSong,
- const CStdString& strTitle, const CStdString& strMusicBrainzTrackID,
- const CStdString& strPathAndFileName, const CStdString& strComment, const CStdString& strThumb,
- const std::vector<std::string>& artists, const std::vector<std::string>& genres,
- int iTrack, int iDuration, int iYear,
- int iTimesPlayed, int iStartOffset, int iEndOffset,
- const CDateTime& dtLastPlayed, char rating, int iKaraokeNumber)
+int CMusicDatabase::UpdateSong(int idSong,
+ const CStdString& strTitle, const CStdString& strMusicBrainzTrackID,
+ const CStdString& strPathAndFileName, const CStdString& strComment, const CStdString& strThumb,
+ const std::vector<std::string>& artists, const std::vector<std::string>& genres,
+ int iTrack, int iDuration, int iYear,
+ int iTimesPlayed, int iStartOffset, int iEndOffset,
+ const CDateTime& dtLastPlayed, char rating, int iKaraokeNumber)
{
CStdString sql;
if (idSong < 0)
@@ -3902,9 +3902,9 @@ bool CMusicDatabase::SaveAlbumThumb(int idAlbum, const CStdString& strThumb)
SetArtForItem(idAlbum, "album", "thumb", strThumb);
// TODO: We should prompt the user to update the art for songs
CStdString sql = PrepareSQL("UPDATE art"
- " SET art_url='-'"
+ " SET url='-'"
" WHERE media_type='song'"
- " AND art_type='thumb'"
+ " AND type='thumb'"
" AND media_id IN"
" (SELECT idSong FROM song WHERE idAlbum=%ld)", idAlbum);
ExecuteQuery(sql);
diff --git a/xbmc/music/infoscanner/MusicInfoScanner.cpp b/xbmc/music/infoscanner/MusicInfoScanner.cpp
index 200f2a95a4..fb9b16a47c 100644
--- a/xbmc/music/infoscanner/MusicInfoScanner.cpp
+++ b/xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -618,7 +618,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
// No - download the information
CMusicAlbumInfo albumInfo;
INFO_RET albumDownloadStatus = INFO_NOT_FOUND;
- if (m_flags & SCAN_ONLINE)
+ if ((m_flags & SCAN_ONLINE) && albumScraper)
albumDownloadStatus = DownloadAlbumInfo(*album, albumScraper, albumInfo);
if (albumDownloadStatus == INFO_ADDED || albumDownloadStatus == INFO_HAVE_ALREADY)
@@ -640,14 +640,18 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
}
else if (albumDownloadStatus == INFO_CANCELLED)
break;
- else // Cache the lookup failure so we don't retry
+ else
{
+ // No download info, fallback to already gathered (eg. local) information/art (if any)
album->idAlbum = m_musicDatabase.AddAlbum(album->strAlbum,
album->strMusicBrainzAlbumID,
album->GetArtistString(),
album->GetGenreString(),
album->iYear,
album->bCompilation);
+ if (!album->art.empty())
+ m_musicDatabase.SetArtForItem(album->idAlbum,
+ "album", album->art);
m_albumCache.insert(make_pair(*album, *album));
}
@@ -676,7 +680,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
// No - download the information
CMusicArtistInfo artistInfo;
INFO_RET artistDownloadStatus = INFO_NOT_FOUND;
- if (m_flags & SCAN_ONLINE)
+ if ((m_flags & SCAN_ONLINE) && artistScraper)
artistDownloadStatus = DownloadArtistInfo(artistTmp, artistScraper, artistInfo);
if (artistDownloadStatus == INFO_ADDED || artistDownloadStatus == INFO_HAVE_ALREADY)
@@ -747,7 +751,7 @@ int CMusicInfoScanner::RetrieveMusicInfo(const CStdString& strDirectory, CFileIt
// No - download the information
CMusicArtistInfo artistInfo;
INFO_RET artistDownloadStatus = INFO_NOT_FOUND;
- if (m_flags & SCAN_ONLINE)
+ if ((m_flags & SCAN_ONLINE) && artistScraper)
artistDownloadStatus = DownloadArtistInfo(artistTmp, artistScraper, artistInfo);
if (artistDownloadStatus == INFO_ADDED || artistDownloadStatus == INFO_HAVE_ALREADY)
@@ -1009,8 +1013,10 @@ void CMusicInfoScanner::FindArtForAlbums(VECALBUMS &albums, const CStdString &pa
}
}
if (albums.size() == 1 && !albumArt.empty())
- { // assign to folder thumb as well
- CMusicThumbLoader::SetCachedImage(path, "thumb", albumArt);
+ {
+ // assign to folder thumb as well
+ CFileItem albumItem(path, true);
+ CMusicThumbLoader::SetCachedImage(albumItem, "thumb", albumArt);
}
}
@@ -1048,10 +1054,13 @@ INFO_RET CMusicInfoScanner::UpdateDatabaseAlbumInfo(const CStdString& strPath, C
// find album info
ADDON::ScraperPtr scraper;
- if (!m_musicDatabase.GetScraperForPath(strPath, scraper, ADDON::ADDON_SCRAPER_ALBUMS) || !scraper)
- return INFO_ERROR;
+ bool result = m_musicDatabase.GetScraperForPath(strPath, scraper, ADDON::ADDON_SCRAPER_ALBUMS);
+
m_musicDatabase.Close();
+ if (!result || !scraper)
+ return INFO_ERROR;
+
loop:
CLog::Log(LOGDEBUG, "%s downloading info for: %s", __FUNCTION__, album.strAlbum.c_str());
INFO_RET albumDownloadStatus = DownloadAlbumInfo(album, scraper, albumInfo, pDialog);
diff --git a/xbmc/music/windows/GUIWindowMusicBase.cpp b/xbmc/music/windows/GUIWindowMusicBase.cpp
index 8b4f0dfd3c..cf8ae67b67 100644
--- a/xbmc/music/windows/GUIWindowMusicBase.cpp
+++ b/xbmc/music/windows/GUIWindowMusicBase.cpp
@@ -339,7 +339,7 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
}
}
- // check the first song we find in the folder, and grab it's album info
+ // check the first song we find in the folder, and grab its album info
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr pItem = items[i];
@@ -347,9 +347,13 @@ void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo)
if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() &&
!pItem->GetMusicInfoTag()->GetAlbum().IsEmpty())
{
- ShowAlbumInfo(pItem.get());
+ bool result = ShowAlbumInfo(pItem.get());
+
if (m_dlgProgress && bShowInfo)
m_dlgProgress->Close();
+
+ if (!result) // Something went wrong, so bail for the rest
+ break;
}
}
@@ -420,7 +424,7 @@ void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo
m_dlgProgress->Close();
}
-void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /* = true */)
+bool CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /* = true */)
{
CQueryParams params;
CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params);
@@ -431,12 +435,19 @@ void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /
!m_musicdatabase.GetAlbumInfo(params.GetAlbumId(), albumInfo.GetAlbum(), &albumInfo.GetAlbum().songs))
{
if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser)
- break; // should display a dialog saying no permissions
+ {
+ // TODO: should display a dialog saying no permissions
+ if (m_dlgProgress)
+ m_dlgProgress->Close();
+ return false;
+ }
if (g_application.IsMusicScanning())
{
CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0);
- break;
+ if (m_dlgProgress)
+ m_dlgProgress->Close();
+ return false;
}
// show dialog box indicating we're searching the album
@@ -453,7 +464,9 @@ void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /
if (scanner.UpdateDatabaseAlbumInfo(pItem->GetPath(), albumInfo, bShowInfo) != INFO_ADDED || !albumInfo.Loaded())
{
CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0);
- break;
+ if (m_dlgProgress)
+ m_dlgProgress->Close();
+ return false;
}
}
@@ -479,6 +492,7 @@ void CGUIWindowMusicBase::ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo /
}
if (m_dlgProgress)
m_dlgProgress->Close();
+ return true;
}
void CGUIWindowMusicBase::ShowSongInfo(CFileItem* pItem)
diff --git a/xbmc/music/windows/GUIWindowMusicBase.h b/xbmc/music/windows/GUIWindowMusicBase.h
index 2b86799f07..6d616dd609 100644
--- a/xbmc/music/windows/GUIWindowMusicBase.h
+++ b/xbmc/music/windows/GUIWindowMusicBase.h
@@ -88,7 +88,7 @@ protected:
bool FindAlbumInfo(const CFileItem* album, MUSIC_GRABBER::CMusicAlbumInfo& albumInfo, ALLOW_SELECTION allowSelection);
bool FindArtistInfo(const CFileItem* artist, MUSIC_GRABBER::CMusicArtistInfo& artistInfo, ALLOW_SELECTION allowSelection);
- void ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo = true);
+ bool ShowAlbumInfo(const CFileItem *pItem, bool bShowInfo = true);
void ShowArtistInfo(const CFileItem *pItem, bool bShowInfo = true);
void ShowSongInfo(CFileItem* pItem);
void UpdateThumb(const CAlbum &album, const CStdString &path);