From fa7385f220de792694250d476a73895bacee18af Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Mon, 24 Nov 2014 18:38:04 +0100 Subject: [PATCH] Support albumArtist whereever possible. --- src/libtomahawk/AlbumPlaylistInterface.cpp | 2 +- src/libtomahawk/ArtistPlaylistInterface.cpp | 2 +- src/libtomahawk/audio/AudioEngine.cpp | 2 +- .../database/DatabaseCommand_AllTracks.cpp | 37 ++++++++++--------- .../database/DatabaseCommand_Resolve.cpp | 18 +++++++-- src/libtomahawk/database/DatabaseImpl.cpp | 22 +++++++---- src/libtomahawk/resolvers/JSResolver.cpp | 1 + src/libtomahawk/resolvers/ScriptResolver.cpp | 9 ++++- src/libtomahawk/utils/JspfLoader.cpp | 2 +- src/libtomahawk/utils/XspfLoader.cpp | 2 +- 10 files changed, 63 insertions(+), 34 deletions(-) diff --git a/src/libtomahawk/AlbumPlaylistInterface.cpp b/src/libtomahawk/AlbumPlaylistInterface.cpp index c5b4f60d9..e4b74e039 100644 --- a/src/libtomahawk/AlbumPlaylistInterface.cpp +++ b/src/libtomahawk/AlbumPlaylistInterface.cpp @@ -198,7 +198,7 @@ AlbumPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData re foreach ( const QString& trackName, tracks ) { - track_ptr track = Track::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], 0, QString(), trackNo++ ); + track_ptr track = Track::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], QString(), 0, QString(), trackNo++ ); query_ptr query = Query::get( track ); if ( query ) ql << query; diff --git a/src/libtomahawk/ArtistPlaylistInterface.cpp b/src/libtomahawk/ArtistPlaylistInterface.cpp index d6a6568d8..bce671177 100644 --- a/src/libtomahawk/ArtistPlaylistInterface.cpp +++ b/src/libtomahawk/ArtistPlaylistInterface.cpp @@ -158,7 +158,7 @@ ArtistPlaylistInterface::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData r foreach ( const QString& trackName, tracks ) { - track_ptr track = Track::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], 0, QString(), trackNo++ ); + track_ptr track = Track::get( inputInfo[ "artist" ], trackName, inputInfo[ "album" ], QString(), 0, QString(), trackNo++ ); query_ptr query = Query::get( track ); if ( query ) ql << query; diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index 83f9b8df0..13564362d 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -942,7 +942,7 @@ AudioEngine::play( const QUrl& url ) if ( !tags.isEmpty() ) { t = Track::get( tags["artist"].toString(), tags["track"].toString(), tags["album"].toString(), - tags["duration"].toInt(), tags["composer"].toString(), + tags["albumArtist"].toString(), tags["duration"].toInt(), tags["composer"].toString(), tags["albumpos"].toUInt(), tags["discnumber"].toUInt() ); } else diff --git a/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp b/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp index 3341e94f5..941b0c11d 100644 --- a/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp +++ b/src/libtomahawk/database/DatabaseCommand_AllTracks.cpp @@ -74,14 +74,16 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi ) } QString sql = QString( - "SELECT file.id, artist.name, album.name, track.name, composer.name, file.size, " //0 - "file.duration, file.bitrate, file.url, file.source, file.mtime, " //6 - "file.mimetype, file_join.discnumber, file_join.albumpos, track.id " //11 + "SELECT file.id, artist.name, album.name, track.name, composer.name, file.size, " //0 + "file.duration, file.bitrate, file.url, file.source, file.mtime, " //6 + "file.mimetype, file_join.discnumber, file_join.albumpos, track.id, albumArtist.name " //11 "FROM file, artist, track, file_join " "LEFT OUTER JOIN album " "ON file_join.album = album.id " "LEFT OUTER JOIN artist AS composer " "ON file_join.composer = composer.id " + "LEFT OUTER JOIN artist AS albumArtist " + "ON album.artist = albumArtist.id " "WHERE file.id = file_join.file " "AND file_join.artist = artist.id " "AND file_join.track = track.id " @@ -104,20 +106,21 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi ) while( query.next() ) { - QString artist = query.value( 1 ).toString(); - QString album = query.value( 2 ).toString(); - QString track = query.value( 3 ).toString(); - QString composer = query.value( 4 ).toString(); - uint size = query.value( 5 ).toUInt(); - uint duration = query.value( 6 ).toUInt(); - uint bitrate = query.value( 7 ).toUInt(); + const QString artist = query.value( 1 ).toString(); + const QString album = query.value( 2 ).toString(); + const QString track = query.value( 3 ).toString(); + const QString composer = query.value( 4 ).toString(); + const uint size = query.value( 5 ).toUInt(); + const uint duration = query.value( 6 ).toUInt(); + const uint bitrate = query.value( 7 ).toUInt(); QString url = query.value( 8 ).toString(); - uint sourceId = query.value( 9 ).toUInt(); - uint modificationTime = query.value( 10 ).toUInt(); - QString mimetype = query.value( 11 ).toString(); - uint discnumber = query.value( 12 ).toUInt(); - uint albumpos = query.value( 13 ).toUInt(); - uint trackId = query.value( 14 ).toUInt(); + const uint sourceId = query.value( 9 ).toUInt(); + const uint modificationTime = query.value( 10 ).toUInt(); + const QString mimetype = query.value( 11 ).toString(); + const uint discnumber = query.value( 12 ).toUInt(); + const uint albumpos = query.value( 13 ).toUInt(); + const uint trackId = query.value( 14 ).toUInt(); + const QString albumArtist = query.value( 15 ).toString(); std::map::const_iterator _s = sourceCache.find( sourceId ); Tomahawk::source_ptr s; @@ -140,7 +143,7 @@ DatabaseCommand_AllTracks::exec( DatabaseImpl* dbi ) Tomahawk::track_ptr t = Tomahawk::Track::get( trackId, artist, track, album, - duration, composer, + albumArtist, duration, composer, albumpos, discnumber ); if ( !t ) continue; diff --git a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp index 1f5743eb8..d5ac22181 100644 --- a/src/libtomahawk/database/DatabaseCommand_Resolve.cpp +++ b/src/libtomahawk/database/DatabaseCommand_Resolve.cpp @@ -110,10 +110,13 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib ) "file_join.albumpos, " //17 "artist.id as artid, " //18 "album.id as albid, " //19 - "composer.id as cmpid " //20 + "composer.id as cmpid, " //20 + "albumArtist.id as albumartistid, " //21 + "albumArtist.name as albumartistname " //22 "FROM file, file_join, artist, track " "LEFT JOIN album ON album.id = file_join.album " "LEFT JOIN artist AS composer ON composer.id = file_join.composer " + "LEFT JOIN artist AS albumArtist ON albumArtist.id = album.artist " "WHERE " "artist.id = file_join.artist AND " "track.id = file_join.track AND " @@ -144,7 +147,9 @@ DatabaseCommand_Resolve::resolve( DatabaseImpl* lib ) continue; } - track_ptr track = Track::get( files_query.value( 9 ).toUInt(), files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() ); + track_ptr track = Track::get( files_query.value( 9 ).toUInt(), files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), + files_query.value( 13 ).toString(), files_query.value( 22 ).toString(), files_query.value( 5 ).toUInt(), + files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() ); if ( !track ) continue; track->loadAttributes(); @@ -223,10 +228,13 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib ) "file_join.albumpos, " //17 "artist.id as artid, " //18 "album.id as albid, " //19 - "composer.id as cmpid " //20 + "composer.id as cmpid, " //20 + "albumArtist.id as albumartistid, " //21 + "albumArtist.name as albumartistname " //22 "FROM file, file_join, artist, track " "LEFT JOIN album ON album.id = file_join.album " "LEFT JOIN artist AS composer ON composer.id = file_join.composer " + "LEFT JOIN artist AS albumArtist ON albumArtist.id = album.artist " "WHERE " "artist.id = file_join.artist AND " "track.id = file_join.track AND " @@ -257,7 +265,9 @@ DatabaseCommand_Resolve::fullTextResolve( DatabaseImpl* lib ) continue; } - track_ptr track = Track::get( files_query.value( 9 ).toUInt(), files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), files_query.value( 13 ).toString(), files_query.value( 5 ).toUInt(), files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() ); + track_ptr track = Track::get( files_query.value( 9 ).toUInt(), files_query.value( 12 ).toString(), files_query.value( 14 ).toString(), + files_query.value( 13 ).toString(), files_query.value( 22 ).toString(), files_query.value( 5 ).toUInt(), + files_query.value( 15 ).toString(), files_query.value( 17 ).toUInt(), files_query.value( 11 ).toUInt() ); track->loadAttributes(); result = Result::get( url, track ); diff --git a/src/libtomahawk/database/DatabaseImpl.cpp b/src/libtomahawk/database/DatabaseImpl.cpp index 59c9d663f..ae802ee86 100644 --- a/src/libtomahawk/database/DatabaseImpl.cpp +++ b/src/libtomahawk/database/DatabaseImpl.cpp @@ -290,11 +290,12 @@ Tomahawk::DatabaseImpl::file( int fid ) TomahawkSqlQuery query = newquery(); query.exec( QString( "SELECT url, mtime, size, md5, mimetype, duration, bitrate, " "file_join.artist, file_join.album, file_join.track, file_join.composer, " - "(select name from artist where id = file_join.artist) as artname, " - "(select name from album where id = file_join.album) as albname, " - "(select name from track where id = file_join.track) as trkname, " - "(select name from artist where id = file_join.composer) as cmpname, " - "source " + "(SELECT name FROM artist WHERE id = file_join.artist) AS artname, " + "(SELECT name FROM album WHERE id = file_join.album) AS albname, " + "(SELECT name FROM track WHERE id = file_join.track) AS trkname, " + "(SELECT name FROM artist WHERE id = file_join.composer) AS cmpname, " + "source, " + "(SELECT artist.name FROM artist, album WHERE artist.id = album.artist AND album.id = file_join.album) AS albumartname " "FROM file, file_join " "WHERE file.id = file_join.file AND file.id = %1" ) .arg( fid ) ); @@ -308,7 +309,9 @@ Tomahawk::DatabaseImpl::file( int fid ) if ( !s->isLocal() ) url = QString( "servent://%1\t%2" ).arg( s->nodeId() ).arg( url ); - Tomahawk::track_ptr track = Tomahawk::Track::get( query.value( 9 ).toUInt(), query.value( 11 ).toString(), query.value( 13 ).toString(), query.value( 12 ).toString(), query.value( 5 ).toUInt(), query.value( 14 ).toString(), 0, 0 ); + Tomahawk::track_ptr track = Tomahawk::Track::get( query.value( 9 ).toUInt(), query.value( 11 ).toString(), query.value( 13 ).toString(), + query.value( 12 ).toString(), query.value( 16 ).toString(), query.value( 5 ).toUInt(), + query.value( 14 ).toString(), 0, 0 ); if ( !track ) return r; r = Tomahawk::Result::get( url, track ); @@ -633,6 +636,7 @@ Tomahawk::DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery ) Tomahawk::track_ptr track = Tomahawk::Track::get( origquery->queryTrack()->artist(), origquery->queryTrack()->track(), origquery->queryTrack()->album(), + QString(), origquery->queryTrack()->duration() ); // Return http resulthint directly @@ -674,10 +678,13 @@ Tomahawk::DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery ) "file_join.discnumber, " //17 "artist.id as artid, " //18 "album.id as albid, " //19 - "composer.id as cmpid " //20 + "composer.id as cmpid, " //20 + "albumArtist.id as albumartistid, " //21 + "albumArtist.name as albumartistname " //22 "FROM file, file_join, artist, track " "LEFT JOIN album ON album.id = file_join.album " "LEFT JOIN artist AS composer on composer.id = file_join.composer " + "LEFT JOIN artist AS albumArtist on albumArtist.id = album.artist " "WHERE " "artist.id = file_join.artist AND " "track.id = file_join.track AND " @@ -703,6 +710,7 @@ Tomahawk::DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery ) query.value( 11 ).toString(), query.value( 13 ).toString(), query.value( 12 ).toString(), + query.value( 22 ).toString(), query.value( 5 ).toInt(), query.value( 14 ).toString(), query.value( 16 ).toUInt(), diff --git a/src/libtomahawk/resolvers/JSResolver.cpp b/src/libtomahawk/resolvers/JSResolver.cpp index 235bc159c..33567c521 100644 --- a/src/libtomahawk/resolvers/JSResolver.cpp +++ b/src/libtomahawk/resolvers/JSResolver.cpp @@ -566,6 +566,7 @@ JSResolver::parseResultVariantList( const QVariantList& reslist ) Tomahawk::track_ptr track = Tomahawk::Track::get( m.value( "artist" ).toString(), m.value( "track" ).toString(), m.value( "album" ).toString(), + m.value( "albumartist" ).toString(), duration, QString(), m.value( "albumpos" ).toUInt(), diff --git a/src/libtomahawk/resolvers/ScriptResolver.cpp b/src/libtomahawk/resolvers/ScriptResolver.cpp index d161c3352..e66a6be66 100644 --- a/src/libtomahawk/resolvers/ScriptResolver.cpp +++ b/src/libtomahawk/resolvers/ScriptResolver.cpp @@ -288,7 +288,14 @@ ScriptResolver::handleMsg( const QByteArray& msg ) QVariantMap m = rv.toMap(); tDebug( LOGVERBOSE ) << "Found result:" << m; - Tomahawk::track_ptr track = Tomahawk::Track::get( m.value( "artist" ).toString(), m.value( "track" ).toString(), m.value( "album" ).toString(), m.value( "duration" ).toUInt(), QString(), m.value( "albumpos" ).toUInt(), m.value( "discnumber" ).toUInt() ); + Tomahawk::track_ptr track = Tomahawk::Track::get( m.value( "artist" ).toString(), + m.value( "track" ).toString(), + m.value( "album" ).toString(), + m.value( "albumartist" ).toString(), + m.value( "duration" ).toUInt(), + QString(), + m.value( "albumpos" ).toUInt(), + m.value( "discnumber" ).toUInt() ); if ( !track ) continue; diff --git a/src/libtomahawk/utils/JspfLoader.cpp b/src/libtomahawk/utils/JspfLoader.cpp index 1ccc1c13b..06a514517 100644 --- a/src/libtomahawk/utils/JspfLoader.cpp +++ b/src/libtomahawk/utils/JspfLoader.cpp @@ -178,7 +178,7 @@ JSPFLoader::gotBody() continue; } - track_ptr t = Tomahawk::Track::get( artist, track, album, duration.toInt() / 1000 ); + track_ptr t = Tomahawk::Track::get( artist, track, album, QString(), duration.toInt() / 1000 ); query_ptr q = Tomahawk::Query::get( t ); if ( !q ) continue; diff --git a/src/libtomahawk/utils/XspfLoader.cpp b/src/libtomahawk/utils/XspfLoader.cpp index 75c951883..b9c939728 100644 --- a/src/libtomahawk/utils/XspfLoader.cpp +++ b/src/libtomahawk/utils/XspfLoader.cpp @@ -291,7 +291,7 @@ XSPFLoader::gotBody() continue; } - track_ptr t = Tomahawk::Track::get( artist, track, album, duration.toInt() / 1000 ); + track_ptr t = Tomahawk::Track::get( artist, track, album, QString(), duration.toInt() / 1000 ); query_ptr q = Tomahawk::Query::get( t ); if ( q.isNull() ) continue;