[gnome-music] query: Rework songs query
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] query: Rework songs query
- Date: Sun, 3 Jan 2016 18:26:08 +0000 (UTC)
commit 571f219f7dbea37ee010bee434aaa8469956a6c1
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Dec 27 00:13:25 2015 +0100
query: Rework songs query
No large functional changes, the path matching is performed using
pure string operations though. The filters for the music pieces
not being videos or playlists has been removed too. If that happens,
it is plainly a Tracker bug, no need to tap over it.
https://bugzilla.gnome.org/show_bug.cgi?id=759587
gnomemusic/query.py | 55 +++++++++++++++++++++-----------------------------
1 files changed, 23 insertions(+), 32 deletions(-)
---
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index c7b3d7d..8182dbf 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -335,39 +335,30 @@ class Query():
@staticmethod
def songs(where_clause):
query = '''
- SELECT DISTINCT
+ SELECT
rdf:type(?song)
- tracker:id(?song) AS id
- nie:url(?song) AS url
- nie:title(?song) AS title
- nmm:artistName(nmm:performer(?song)) AS artist
- nie:title(nmm:musicAlbum(?song)) AS album
- nfo:duration(?song) AS duration
- IF(bound(?tag), 'truth!', '') AS lyrics
- {
- %(where_clause)s
- OPTIONAL {
- ?song nao:hasTag ?tag .
- FILTER( ?tag = nao:predefined-tag-favorite )
- }
- FILTER (
- tracker:uri-is-descendant(
- '%(music_dir)s', nie:url(?song)
- ) ||
- tracker:uri-is-descendant(
- '%(download_dir)s', nie:url(?song)
- )
- )
- FILTER (
- NOT EXISTS {
- ?song a nmm:Video
- } &&
- NOT EXISTS {
- ?song a nmm:Playlist
- }
- )
- }
- ORDER BY ?artist ?album nmm:setNumber(nmm:musicAlbumDisc(?song)) nmm:trackNumber(?song)
+ tracker:id (?song) AS ?id
+ ?url
+ nie:title(?song) AS ?title
+ nmm:artistName (nmm:performer(?song)) AS ?artist
+ nie:title (nmm:musicAlbum (?song)) AS ?album
+ nfo:duration (?song) AS ?duration
+ IF (BOUND (?tag), 'b', '') AS ?lyrics
+ {
+ %(where_clause)s
+ ?song a nmm:MusicPiece ;
+ nmm:musicAlbumDisc ?disc ;
+ 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, '%(download_dir)s/') ||
+ STRSTARTS (?url, '%(music_dir)s/'))
+ }
+ ORDER BY ?artist ?album nmm:setNumber(?disc) nmm:trackNumber(?song)
'''.replace('\n', ' ').strip() % {
'where_clause': where_clause.replace('\n', ' ').strip(),
'music_dir': Query.MUSIC_URI,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]