diff options
author | Jonathan Marshall <jmarshall@xbmc.org> | 2013-12-01 20:57:24 +1300 |
---|---|---|
committer | Jonathan Marshall <jmarshall@xbmc.org> | 2013-12-24 13:48:55 +1300 |
commit | c57ca58944eb3e5413710ff9f8fa4fcf8da7420a (patch) | |
tree | cbb9e2bc498dd5c45c7dd312d57175734b438278 | |
parent | d0bd242d630946bbea9db8fd2e5aa29f64be710d (diff) |
[musicdb] If we're rescanning an album from tags (i.e. tags have changed) make sure we update the album as best we can.
This includes:
1. Update genre, year, compilation.
2. If a MBID exists, also update album name and album artist (as these may differ as we match on MBID).
3. Reset lastScraped time so that online metadata is refreshed.
4. Ensure we remove previously assigned album artists before adding the current ones.
5. Ensure we remove previously assigned album genres before adding the current ones.
The main place this process can fail is in multi-folder albums. In this case, the artists and genres (and year and compilation flag)
from the last scanned folder will be what is included.
A way to work around this for the future might be that, in the scanner, we not only scan the current folder, but for each album, we
grab all other folders those albums appear on and scan them at the same time. This ensures that each album is complete during an
individual scan.
-rw-r--r-- | xbmc/music/MusicDatabase.cpp | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp index e8008214fd..449d3bf1a4 100644 --- a/xbmc/music/MusicDatabase.cpp +++ b/xbmc/music/MusicDatabase.cpp @@ -776,17 +776,34 @@ int CMusicDatabase::AddAlbum(const CStdString& strAlbum, const CStdString& strMu } else { - // exists in our database and not scanned during this scan, so we should update it as the details - // may have changed (there's a reason we're rescanning, afterall!) + /* Exists in our database and being re-scanned from tags, so we should update it as the details + may have changed. + + Note that for multi-folder albums this will mean the last folder scanned will have the information + stored for it. Most values here should be the same across all songs anyway, but it does mean + that if there's any inconsistencies then only the last folders information will be taken. + + We make sure we clear out the link tables (album artists, album genres) and we reset + the last scraped time to make sure that online metadata is re-fetched. */ int idAlbum = m_pDS->fv("idAlbum").get_asInt(); m_pDS->close(); - strSQL=PrepareSQL("update album set strGenres='%s', iYear=%i where idAlbum=%i", strGenre.c_str(), year, idAlbum); - m_pDS->exec(strSQL.c_str()); - // and clear the link tables - these are updated in AddSong() - strSQL=PrepareSQL("delete from album_artist where idAlbum=%i", idAlbum); - m_pDS->exec(strSQL.c_str()); - strSQL=PrepareSQL("delete from album_genre where idAlbum=%i", idAlbum); + if (strMusicBrainzAlbumID.empty()) + strSQL=PrepareSQL("UPDATE album SET strGenres = '%s', iYear=%i, bCompilation=%i, lastScraped = NULL WHERE idAlbum=%i", + strGenre.c_str(), + year, + bCompilation, + idAlbum); + else + strSQL=PrepareSQL("UPDATE album SET strAlbum = '%s', strArtists = '%s', strGenres = '%s', iYear=%i, bCompilation=%i, lastScraped = NULL WHERE idAlbum=%i", + strAlbum.c_str(), + strArtist.c_str(), + strGenre.c_str(), + year, + bCompilation, + idAlbum); m_pDS->exec(strSQL.c_str()); + DeleteAlbumArtistsByAlbum(idAlbum); + DeleteAlbumGenresByAlbum(idAlbum); return idAlbum; } } |