Skip to content
This repository
Browse code

[musicdb] cosmetic: Add HasArtistInfo and make GetArtistInfo use the …

…views, for consistency with albums
  • Loading branch information...
commit 84216cefeb464c374c331ef5ac120f1c7b2ffb3b 1 parent 901c7d5
night199uk authored April 09, 2013
16  xbmc/music/MusicDatabase.cpp
@@ -1310,16 +1310,7 @@ bool CMusicDatabase::GetArtistInfo(int idArtist, CArtist &info, bool needAll)
1310 1310
     if (idArtist == -1)
1311 1311
       return false; // not in the database
1312 1312
 
1313  
-    CStdString strSQL=PrepareSQL("SELECT artist.idArtist AS idArtist, strArtist, "
1314  
-                                 "  strBorn, strFormed, strGenres,"
1315  
-                                 "  strMoods, strStyles, strInstruments, "
1316  
-                                 "  strBiography, strDied, strDisbanded, "
1317  
-                                 "  strYearsActive, strImage, strFanart "
1318  
-                                 "  FROM artist "
1319  
-                                 "  JOIN artistinfo "
1320  
-                                 "    ON artist.idArtist = artistinfo.idArtist "
1321  
-                                 "  WHERE artistinfo.idArtist = %i"
1322  
-                                 , idArtist);
  1313
+    CStdString strSQL=PrepareSQL("SELECT * FROM artistview WHERE idArtist = %i", idArtist);
1323 1314
 
1324 1315
     if (!m_pDS2->query(strSQL.c_str())) return false;
1325 1316
     int iRowsFound = m_pDS2->num_rows();
@@ -1350,6 +1341,11 @@ bool CMusicDatabase::GetArtistInfo(int idArtist, CArtist &info, bool needAll)
1350 1341
   return false;
1351 1342
 }
1352 1343
 
  1344
+bool CMusicDatabase::HasArtistInfo(int idArtist)
  1345
+{
  1346
+  return strtol(GetSingleValue("artistinfo", "count(idArtist)", PrepareSQL("idArtist = %ld", idArtist)), NULL, 10) > 0;
  1347
+}
  1348
+
1353 1349
 bool CMusicDatabase::DeleteArtistInfo(int idArtist)
1354 1350
 {
1355 1351
   if (idArtist == -1)
6  xbmc/music/MusicDatabase.h
@@ -117,6 +117,12 @@ class CMusicDatabase : public CDatabase
117 117
   bool GetAlbumInfo(int idAlbum, CAlbum &info, VECSONGS* songs, bool scrapedInfo = false);
118 118
   bool HasAlbumInfo(int idAlbum);
119 119
   bool GetArtistInfo(int idArtist, CArtist &info, bool needAll=true);
  120
+
  121
+  /*! \brief Check if an artist entity has additional metadata (scraped)
  122
+   \param idArtist the id of the Artist to check
  123
+   \return true or false - whether the artist has metadata
  124
+   */
  125
+  bool HasArtistInfo(int idArtist);
120 126
   bool GetSongByFileName(const CStdString& strFileName, CSong& song, int startOffset = 0);
121 127
   int GetAlbumIdByPath(const CStdString& path);
122 128
   bool GetSongById(int idSong, CSong& song);
2  xbmc/music/infoscanner/MusicInfoScanner.cpp
@@ -1153,7 +1153,7 @@ bool CMusicInfoScanner::DownloadArtistInfo(const CStdString& strPath, const CStd
1153 1153
   bCanceled = false;
1154 1154
   CArtist artist;
1155 1155
   m_musicDatabase.Open();
1156  
-  if (m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info
  1156
+  if (m_musicDatabase.HasArtistInfo(params.GetArtistId()) && m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info
1157 1157
     return true;
1158 1158
 
1159 1159
   // find artist info

0 notes on commit 84216ce

Please sign in to comment.
Something went wrong with that request. Please try again.