[gnome-music] grltrackerwrapper: Prefer albumartist for artist search



commit 704c9b9e80c20587d2bbe2acd227a6c8807c9752
Author: Chinmay Gurjar <chnmgurjar gmail com>
Date:   Sat Apr 11 15:15:45 2020 +0530

    grltrackerwrapper: Prefer albumartist for artist search
    
    Since dd0e665285 the artists query prefers 'albumartist' over the
    'artist' tag. The artist search query did not yet follow this, which
    gave incongruent results.
    
    Use 'albumartist' tag over 'artist' for artist searches if available.

 gnomemusic/grilowrappers/grltrackerwrapper.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gnomemusic/grilowrappers/grltrackerwrapper.py b/gnomemusic/grilowrappers/grltrackerwrapper.py
index f31aeb1e..4997640e 100644
--- a/gnomemusic/grilowrappers/grltrackerwrapper.py
+++ b/gnomemusic/grilowrappers/grltrackerwrapper.py
@@ -698,13 +698,19 @@ class GrlTrackerWrapper(GObject.GObject):
         query = """
         SELECT DISTINCT
             rdf:type(?artist)
-            tracker:id(?artist) AS ?id
+            COALESCE(tracker:id(?album_artist), tracker:id(?artist)) AS ?id
         WHERE {
             ?song a nmm:MusicPiece ;
                     nmm:musicAlbum ?album ;
                     nmm:performer ?artist .
-            BIND(tracker:normalize(
-                nmm:artistName(nmm:albumArtist(?album)), 'nfkd') AS ?match1) .
+            OPTIONAL {
+                ?album a nmm:MusicAlbum ;
+                         nmm:albumArtist ?album_artist .
+            }
+            BIND(COALESCE(nmm:artistName(?album_artist),
+                          nmm:artistName(?artist)) AS ?artist_bind)
+            BIND(tracker:normalize(nmm:artistName(
+                nmm:albumArtist(?artist_bind)), 'nfkd') AS ?match1) .
             BIND(tracker:normalize(
                 nmm:artistName(nmm:performer(?song)), 'nfkd') AS ?match2) .
             BIND(tracker:normalize(nmm:composer(?song), 'nfkd') AS ?match4) .


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]