Commit 09980019 authored by Marinus Schraal's avatar Marinus Schraal

query: Handle optional album-artist

Most tracker extractors were filling the album-artist field with some
form of album-artist/performer/artist, which made this field nearly
always available. Instead tracker should now only expose fields that are
available (https://bugzilla.gnome.org/show_bug.cgi?id=773697) and as a
consequence music should treat album-artist as an optional component in
it's queries.

https://bugzilla.gnome.org/show_bug.cgi?id=774260
parent 5d1ab1fe
......@@ -38,7 +38,7 @@ PKG_CHECK_MODULES(MEDIAART, [libmediaart-2.0])
PYGOBJECT_MIN_VERSION=3.21.1
PKG_CHECK_MODULES(PYGOBJECT, [pygobject-3.0 >= $PYGOBJECT_MIN_VERSION])
TRACKER_MIN_VERSION=1.9.0
TRACKER_MIN_VERSION=1.11.0
PKG_CHECK_MODULES(TRACKER, [tracker-sparql-1.0 >= $TRACKER_MIN_VERSION])
GLIB_COMPILE_RESOURCES=`$PKG_CONFIG --variable glib_compile_resources gio-2.0`
......
......@@ -151,22 +151,22 @@ class Query():
?song a nmm:MusicPiece ;
nmm:musicAlbum ?album ;
nmm:performer ?performer .
?album nmm:albumArtist ?albumArtist ;
nie:title ?title .
BIND(LCASE(?title) AS ?title_lower) .
BIND(LCASE(nmm:artistName(?albumArtist)) AS ?artist_lower) .
BIND((%(album_order)s) AS ?album_collation) .
BIND((%(artist_order)s) AS ?artist_collation) .
?album nie:title ?title .
OPTIONAL { ?album nmm:albumArtist ?albumArtist . }
OPTIONAL { ?song nmm:composer ?composer . }
BIND(tracker:coalesce(nmm:artistName(?albumArtist),
nmm:artistName(?performer)) AS ?artist_presort)
BIND(LCASE(?title) AS ?title_lower)
BIND((%(album_order)s) AS ?album_collation)
FILTER(STRSTARTS(nie:url(?song), '%(music_dir)s/'))
}
GROUP BY ?album
ORDER BY ?album_collation ?artist_collation ?creation_date
ORDER BY ?album_collation (%(artist_sort)s) ?creation_date
""".replace('\n', ' ').strip() % {
'where_clause': where_clause.replace('\n', ' ').strip(),
'music_dir': Query.MUSIC_URI,
'album_order': Query._order_by_statement("?title_lower"),
'artist_order': Query._order_by_statement("?artist_lower"),
'artist_sort': Query._order_by_statement("?artist_presort"),
}
return query
......@@ -185,22 +185,22 @@ class Query():
{
%(where_clause)s
?album a nmm:MusicAlbum ;
nmm:albumArtist ?albumArtist ;
nie:title ?title .
?song nmm:musicAlbum ?album ;
nmm:performer ?performer .
BIND(LCASE(nmm:artistName(?albumArtist)) AS ?artist_lower) .
BIND(LCASE(?title) AS ?title_lower) .
BIND((%(artist_order)s) AS ?artist_collation) .
BIND((%(album_order)s) AS ?title_collation) .
OPTIONAL { ?album nmm:albumArtist ?albumArtist }
BIND(tracker:coalesce(nmm:artistName(?albumArtist),
nmm:artistName(?performer)) AS ?artist_presort)
BIND(LCASE(?title) AS ?title_lower)
BIND((%(album_order)s) AS ?title_collation)
FILTER(STRSTARTS(nie:url(?song), '%(music_dir)s/'))
}
GROUP BY ?album
ORDER BY ?artist_collation ?creation_date ?album_collation
ORDER BY (%(artist_sort)s) ?creation_date ?album_collation
""".replace('\n', ' ').strip() % {
'where_clause': where_clause.replace('\n', ' ').strip(),
'music_dir': Query.MUSIC_URI,
'artist_order': Query._order_by_statement("?artist_lower"),
'artist_sort': Query._order_by_statement("?artist_presort"),
'album_order': Query._order_by_statement("?title_lower")
}
......@@ -225,8 +225,6 @@ class Query():
nmm:musicAlbum ?album ;
nmm:performer ?performer ;
nie:url ?url .
?album nmm:albumArtist ?albumArtist ;
nie:title ?title .
OPTIONAL { ?song nao:hasTag ?tag .
FILTER (?tag = nao:predefined-tag-favorite) } .
FILTER(STRSTARTS(?url, '%(music_dir)s/'))
......@@ -353,17 +351,14 @@ class Query():
SELECT DISTINCT
rdf:type(?album)
tracker:id(?album) AS ?id
(
SELECT
nmm:artistName(?album_artist)
WHERE {
?album nmm:albumArtist ?album_artist
}
LIMIT 1
) AS ?artist
nmm:artistName(?album_artist) AS ?artist
nie:title(?album) AS ?album
WHERE {
?album a nmm:MusicAlbum .
?song a nmm:MusicPiece ;
nmm:musicAlbum ?album ;
nmm:performer ?song_artist .
OPTIONAL { ?album nmm:albumArtist ?album_artist . }
FILTER (
tracker:id(?album) = %(album_id)s
)
......@@ -381,18 +376,13 @@ class Query():
SELECT DISTINCT
rdf:type(?album)
tracker:id(?album) AS ?id
(
SELECT
nmm:artistName(?album_artist)
WHERE {
?album nmm:albumArtist ?album_artist
}
LIMIT 1
) AS ?artist
nmm:artistName(?album_artist) AS ?artist
nie:title(?album) AS ?album
WHERE {
?song a nmm:MusicPiece ;
nmm:musicAlbum ?album .
nmm:musicAlbum ?album ;
nmm:performer ?song_artist .
OPTIONAL { ?album nmm:albumArtist ?album_artist . }
FILTER (
tracker:id(?song) = %(song_id)s
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment