aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marshall <jmarshall@xbmc.org>2013-11-30 19:58:57 +1300
committerJonathan Marshall <jmarshall@xbmc.org>2013-12-24 13:48:49 +1300
commit69de842c4492924ebf6cea0ea54da6577fb12385 (patch)
tree9a597c67b04b573dbe751490ce45e4a36257f063
parent54732006e9462563c69bd1611b52830fb896bd1c (diff)
[musicdb] cosmetic: use ExecQuery for UpdateSong
-rw-r--r--xbmc/music/MusicDatabase.cpp61
1 files changed, 28 insertions, 33 deletions
diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp
index 39b0e0bd18..02a701bfba 100644
--- a/xbmc/music/MusicDatabase.cpp
+++ b/xbmc/music/MusicDatabase.cpp
@@ -483,43 +483,38 @@ int CMusicDatabase::UpdateSong(int idSong,
int iTimesPlayed, int iStartOffset, int iEndOffset,
const CDateTime& dtLastPlayed, char rating, int iKaraokeNumber)
{
- CStdString sql;
if (idSong < 0)
return -1;
CStdString strSQL;
- try
- {
- CStdString strPath, strFileName;
- URIUtils::Split(strPathAndFileName, strPath, strFileName);
- int idPath = AddPath(strPath);
- DWORD crc = ComputeCRC(strFileName);
-
- strSQL = PrepareSQL("UPDATE song SET idPath = %i, strArtists = '%s', strGenres = '%s', strTitle = '%s', iTrack = %i, iDuration = %i, iYear = %i, dwFileNameCRC = '%ul', strFileName = '%s'",
- idPath,
- StringUtils::Join(artists, g_advancedSettings.m_musicItemSeparator).c_str(),
- StringUtils::Join(genres, g_advancedSettings.m_musicItemSeparator).c_str(),
- strTitle.c_str(),
- iTrack, iDuration, iYear,
- crc, strFileName.c_str());
- if (strMusicBrainzTrackID.empty())
- strSQL += PrepareSQL(", strMusicBrainzTrackID = NULL");
- else
- strSQL += PrepareSQL(", strMusicBrainzTrackID = '%s'", strMusicBrainzTrackID.c_str());
-
- if (dtLastPlayed.IsValid())
- strSQL += PrepareSQL(", iTimesPlayed = %i, iStartOffset = %i, iEndOffset = %i, lastplayed = '%s', rating = '%c', comment = '%s'",
- iTimesPlayed, iStartOffset, iEndOffset, dtLastPlayed.GetAsDBDateTime().c_str(), rating, strComment.c_str());
- else
- strSQL += PrepareSQL(", iTimesPlayed = %i, iStartOffset = %i, iEndOffset = %i, lastplayed = NULL, rating = '%c', comment = '%s'",
- iTimesPlayed, iStartOffset, iEndOffset, rating, strComment.c_str());
- strSQL += PrepareSQL(" WHERE idSong = %i", idSong);
- m_pDS->exec(strSQL.c_str());
- }
- catch (...)
- {
- CLog::Log(LOGERROR, "musicdatabase:unable to addsong (%s)", strSQL.c_str());
- }
+ CStdString strPath, strFileName;
+ URIUtils::Split(strPathAndFileName, strPath, strFileName);
+ int idPath = AddPath(strPath);
+ DWORD crc = ComputeCRC(strFileName);
+
+ strSQL = PrepareSQL("UPDATE song SET idPath = %i, strArtists = '%s', strGenres = '%s', strTitle = '%s', iTrack = %i, iDuration = %i, iYear = %i, dwFileNameCRC = '%ul', strFileName = '%s'",
+ idPath,
+ StringUtils::Join(artists, g_advancedSettings.m_musicItemSeparator).c_str(),
+ StringUtils::Join(genres, g_advancedSettings.m_musicItemSeparator).c_str(),
+ strTitle.c_str(),
+ iTrack, iDuration, iYear,
+ crc, strFileName.c_str());
+ if (strMusicBrainzTrackID.empty())
+ strSQL += PrepareSQL(", strMusicBrainzTrackID = NULL");
+ else
+ strSQL += PrepareSQL(", strMusicBrainzTrackID = '%s'", strMusicBrainzTrackID.c_str());
+
+ if (dtLastPlayed.IsValid())
+ strSQL += PrepareSQL(", iTimesPlayed = %i, iStartOffset = %i, iEndOffset = %i, lastplayed = '%s', rating = '%c', comment = '%s'",
+ iTimesPlayed, iStartOffset, iEndOffset, dtLastPlayed.GetAsDBDateTime().c_str(), rating, strComment.c_str());
+ else
+ strSQL += PrepareSQL(", iTimesPlayed = %i, iStartOffset = %i, iEndOffset = %i, lastplayed = NULL, rating = '%c', comment = '%s'",
+ iTimesPlayed, iStartOffset, iEndOffset, rating, strComment.c_str());
+ strSQL += PrepareSQL(" WHERE idSong = %i", idSong);
+
+ bool status = ExecuteQuery(strSQL);
+ if (status)
+ AnnounceUpdate("song", idSong);
return idSong;
}