aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marshall <jmarshall@xbmc.org>2013-12-03 12:12:54 +1300
committerJonathan Marshall <jmarshall@xbmc.org>2013-12-24 13:48:55 +1300
commit62e1da7001067f94a788cd119b36d7a9cb44eff9 (patch)
tree77bc108ec66c03a13db73d931dfe6aa632296f51
parentc57ca58944eb3e5413710ff9f8fa4fcf8da7420a (diff)
[musicdb] Use GetArtistInfo() in ExportToXML to save custom queries.
-rw-r--r--xbmc/music/MusicDatabase.cpp42
1 files changed, 14 insertions, 28 deletions
diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp
index 449d3bf1a4..5e4466322d 100644
--- a/xbmc/music/MusicDatabase.cpp
+++ b/xbmc/music/MusicDatabase.cpp
@@ -4883,35 +4883,23 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo
}
// find all artists
- sql = "SELECT artist.idArtist AS idArtist, strArtist, "
- " strMusicBrainzArtistID, "
- " strBorn, strFormed, strGenres, "
- " strMoods, strStyles, strInstruments, "
- " strBiography, strDied, strDisbanded, "
- " strYearsActive, strImage, strFanart "
- " FROM artist "
- " JOIN artistinfo "
- " ON artist.idArtist=artistinfo.idArtist";
-
- // needed due to getartistpath
- auto_ptr<dbiplus::Dataset> pDS;
- pDS.reset(m_pDB->CreateDataset());
- pDS->query(sql.c_str());
-
- total = pDS->num_rows();
+ vector<int> artistIds;
+ CStdString artistSQL = "SELECT idArtist FROM artistinfo";
+ m_pDS->query(artistSQL.c_str());
+ total = m_pDS->num_rows();
current = 0;
+ artistIds.reserve(total);
+ while (!m_pDS->eof())
+ {
+ artistIds.push_back(m_pDS->fv("idArtist").get_asInt());
+ m_pDS->next();
+ }
+ m_pDS->close();
- while (!pDS->eof())
+ for (vector<int>::iterator artistId = artistIds.begin(); artistId != artistIds.end(); ++artistId)
{
- CArtist artist = GetArtistFromDataset(pDS.get());
- CStdString strSQL=PrepareSQL("select * from discography where idArtist=%i",artist.idArtist);
- m_pDS->query(strSQL.c_str());
- while (!m_pDS->eof())
- {
- artist.discography.push_back(make_pair(m_pDS->fv("strAlbum").get_asString(),m_pDS->fv("strYear").get_asString()));
- m_pDS->next();
- }
- m_pDS->close();
+ CArtist artist;
+ GetArtistInfo(*artistId, artist);
CStdString strPath;
GetArtistPath(artist.idArtist,strPath);
artist.Save(pMain, "artist", strPath);
@@ -4964,10 +4952,8 @@ void CMusicDatabase::ExportToXML(const CStdString &xmlFile, bool singleFiles, bo
return;
}
}
- pDS->next();
current++;
}
- pDS->close();
if (progress)
progress->Close();