Permalink
Browse files

Bump db for song table index change. Musicbrainz track id is not uniq…

…ue on an album, the same recording can be repeated e.g. [Silence] tracks or duplications on a disc set. Load these songs correctly into the music library.
  • Loading branch information...
DaveTBlake committed Feb 24, 2017
1 parent ac10c3d commit 1445e5b5dabb71e3ad643e8531e29bb8c1c9cf02
Showing with 7 additions and 5 deletions.
  1. +1 −1 xbmc/music/Album.cpp
  2. +6 −4 xbmc/music/MusicDatabase.cpp
@@ -254,7 +254,7 @@ void CAlbum::MergeScrapedAlbum(const CAlbum& source, bool override /* = true */)
{
if (!song->strMusicBrainzTrackID.empty())
for (VECSONGS::const_iterator sourceSong = source.infoSongs.begin(); sourceSong != source.infoSongs.end(); ++sourceSong)
if (sourceSong->strMusicBrainzTrackID == song->strMusicBrainzTrackID)
if ((sourceSong->strMusicBrainzTrackID == song->strMusicBrainzTrackID) && (sourceSong->iTrack == song->iTrack))
song->MergeScrapedSong(*sourceSong, override);
}
}
@@ -230,7 +230,8 @@ void CMusicDatabase::CreateAnalytics()
m_pDS->exec("CREATE INDEX idxSong2 ON song(lastplayed)");
m_pDS->exec("CREATE INDEX idxSong3 ON song(idAlbum)");
m_pDS->exec("CREATE INDEX idxSong6 ON song( idPath, strFileName(255) )");
m_pDS->exec("CREATE UNIQUE INDEX idxSong7 ON song( idAlbum, strMusicBrainzTrackID(36) )");
//Musicbrainz Track ID is not unique on an album, recordings are sometimes repeated e.g. "[silence]" or on a disc set
m_pDS->exec("CREATE UNIQUE INDEX idxSong7 ON song( idAlbum, iTrack, strMusicBrainzTrackID(36) )");

m_pDS->exec("CREATE UNIQUE INDEX idxSongArtist_1 ON song_artist ( idSong, idArtist, idRole )");
m_pDS->exec("CREATE INDEX idxSongArtist_2 ON song_artist ( idSong, idRole )");
@@ -684,8 +685,9 @@ int CMusicDatabase::AddSong(const int idAlbum,
int idPath = AddPath(strPath);

if (!strMusicBrainzTrackID.empty())
strSQL = PrepareSQL("SELECT idSong FROM song WHERE idAlbum = %i AND strMusicBrainzTrackID = '%s'",
idAlbum,
strSQL = PrepareSQL("SELECT idSong FROM song WHERE idAlbum = %i AND iTrack=%i AND strMusicBrainzTrackID = '%s'",
idAlbum,
iTrack,
strMusicBrainzTrackID.c_str());
else
strSQL = PrepareSQL("SELECT idSong FROM song WHERE idAlbum=%i AND strFileName='%s' AND strTitle='%s' AND iTrack=%i AND strMusicBrainzTrackID IS NULL",
@@ -5196,7 +5198,7 @@ void CMusicDatabase::UpdateTables(int version)

int CMusicDatabase::GetSchemaVersion() const
{
return 63;
return 64;
}

int CMusicDatabase::GetMusicNeedsTagScan()

0 comments on commit 1445e5b

Please sign in to comment.