aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Blake <oak99sky@yahoo.co.uk>2017-09-08 11:52:38 +0100
committerGitHub <noreply@github.com>2017-09-08 11:52:38 +0100
commit07424d36cdb230162d0822bfea7b65f18fbee508 (patch)
tree7f6a75d17a1cc96f64f565810b9ed99a8c3b956b
parent98dec3c10057c6a7326cb28479e585b9f2996aab (diff)
parente8840a7531eb45bccc0066964138631a216ecbbf (diff)
Merge pull request #12750 from DaveTBlake/KGenreByArtist
[Fix] [Backport] GetGenresByArtist for album artists
-rw-r--r--xbmc/music/MusicDatabase.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/xbmc/music/MusicDatabase.cpp b/xbmc/music/MusicDatabase.cpp
index ef110a2c0f..015facfe37 100644
--- a/xbmc/music/MusicDatabase.cpp
+++ b/xbmc/music/MusicDatabase.cpp
@@ -1758,17 +1758,34 @@ bool CMusicDatabase::GetGenresByArtist(int idArtist, CFileItem* item)
{
try
{
- std::string strSQL = PrepareSQL("SELECT DISTINCT song_genre.idGenre, genre.strGenre FROM "
- "song_artist JOIN song ON song_artist.idSong = song.idSong JOIN "
- "song_genre ON song.idSong = song_genre.idSong JOIN "
- "genre ON song_genre.idGenre = genre.idGenre "
- "WHERE song_artist.idArtist = %i ORDER BY song_genre.idGenre", idArtist);
+ std::string strSQL;
+ strSQL = PrepareSQL("SELECT DISTINCT song_genre.idGenre, genre.strGenre FROM "
+ "album_artist JOIN song ON album_artist.idAlbum = song.idAlbum "
+ "JOIN song_genre ON song.idSong = song_genre.idSong "
+ "JOIN genre ON song_genre.idGenre = genre.idGenre "
+ "WHERE album_artist.idArtist = %i "
+ "ORDER BY song_genre.idGenre", idArtist);
if (!m_pDS->query(strSQL))
return false;
if (m_pDS->num_rows() == 0)
{
+ // Artist does have any song genres via albums may not be an album artist.
+ // Check via songs artist to fetch song genres from compilations or where they are guest artist
m_pDS->close();
- return true;
+ strSQL = PrepareSQL("SELECT DISTINCT song_genre.idGenre, genre.strGenre FROM "
+ "song_artist JOIN song ON song_artist.idSong = song.idSong JOIN "
+ "song_genre ON song.idSong = song_genre.idSong "
+ "JOIN genre ON song_genre.idGenre = genre.idGenre "
+ "WHERE song_artist.idArtist = %i "
+ "ORDER BY song_genre.idGenre", idArtist);
+ if (!m_pDS->query(strSQL))
+ return false;
+ if (m_pDS->num_rows() == 0)
+ {
+ //No song genres, but query sucessfull
+ m_pDS->close();
+ return true;
+ }
}
CVariant artistSongGenres(CVariant::VariantTypeArray);