From 8e199f9faf2a409b98d3049440d6d1eab1217a30 Mon Sep 17 00:00:00 2001 From: hansschmucker Date: Sat, 8 Nov 2014 15:00:03 +0100 Subject: [PATCH 1/3] Use albumartist in DatabaseCommand_AddFiles So far, the album database uses the track artist. This changes it to use the album artist if one is available. --- src/libtomahawk/database/DatabaseCommand_AddFiles.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp b/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp index b0ed37c43..dc7ffc9ab 100644 --- a/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp +++ b/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp @@ -94,7 +94,7 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi ) QVariant& v = *it; QVariantMap m = v.toMap(); - int fileid = 0, artistid = 0, albumid = 0, trackid = 0, composerid = 0; + int fileid = 0, artistid = 0, albumartistid = 0, albumid = 0, trackid = 0, composerid = 0; QString url = m.value( "url" ).toString(); int mtime = m.value( "mtime" ).toInt(); @@ -104,6 +104,7 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi ) uint duration = m.value( "duration" ).toUInt(); uint bitrate = m.value( "bitrate" ).toUInt(); QString artist = m.value( "artist" ).toString(); + QString albumartist = m.value( "albumartist" ).toString(); QString album = m.value( "album" ).toString(); QString track = m.value( "track" ).toString(); uint albumpos = m.value( "albumpos" ).toUInt(); @@ -130,13 +131,18 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi ) // this is the qvariant(map) the remote will get v = m; + // add the album artist to the artist database + albumartistid = dbi->artistId( albumartist, true ); + artistid = dbi->artistId( artist, true ); if ( artistid < 1 ) continue; trackid = dbi->trackId( artistid, track, true ); if ( trackid < 1 ) continue; - albumid = dbi->albumId( artistid, album, true ); + + // If there's an album artist, use it. Otherwise use the track artist + albumid = dbi->albumId( albumartistid > 0 ? albumartistid : artistid, album, true ); if( !composer.trimmed().isEmpty() ) composerid = dbi->artistId( composer, true ); From 9e710da93dace8b4efdb482ca3e52b34e13fc117 Mon Sep 17 00:00:00 2001 From: hansschmucker Date: Thu, 13 Nov 2014 15:30:43 +0100 Subject: [PATCH 2/3] Check whether albumartist is blank before trying to add it. --- src/libtomahawk/database/DatabaseCommand_AddFiles.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp b/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp index dc7ffc9ab..ac35f6269 100644 --- a/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp +++ b/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp @@ -134,7 +134,8 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi ) // add the album artist to the artist database albumartistid = dbi->artistId( albumartist, true ); - artistid = dbi->artistId( artist, true ); + if( !artist.trimmed().isEmpty() ) + artistid = dbi->artistId( artist, true ); if ( artistid < 1 ) continue; trackid = dbi->trackId( artistid, track, true ); From 68af1d1e4bf554c8740ab7c37278161cc43c7cf6 Mon Sep 17 00:00:00 2001 From: hansschmucker Date: Thu, 13 Nov 2014 16:01:13 +0100 Subject: [PATCH 3/3] Only add albumartist if it's non-empty --- src/libtomahawk/database/DatabaseCommand_AddFiles.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp b/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp index ac35f6269..1c3f10d49 100644 --- a/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp +++ b/src/libtomahawk/database/DatabaseCommand_AddFiles.cpp @@ -131,8 +131,9 @@ DatabaseCommand_AddFiles::exec( DatabaseImpl* dbi ) // this is the qvariant(map) the remote will get v = m; - // add the album artist to the artist database - albumartistid = dbi->artistId( albumartist, true ); + // add the album artist to the artist database. + if( !albumartist.trimmed().isEmpty() ) + albumartistid = dbi->artistId( albumartist, true ); if( !artist.trimmed().isEmpty() ) artistid = dbi->artistId( artist, true );