[gnome-music/wip/mschraal/sparql-property-path: 6/6] query: Use some of the new SPARQL syntax
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/sparql-property-path: 6/6] query: Use some of the new SPARQL syntax
- Date: Thu, 21 Feb 2019 16:07:02 +0000 (UTC)
commit cd7d8a0d5945b0a9ef1e407059a0a9ef51946ccf
Author: Marinus Schraal <mschraal gnome org>
Date: Fri Nov 16 15:16:28 2018 +0100
query: Use some of the new SPARQL syntax
Bump the tracker dependency to 2.2.0.
gnomemusic/query.py | 34 ++++++++++++----------------------
meson.build | 2 +-
2 files changed, 13 insertions(+), 23 deletions(-)
---
diff --git a/gnomemusic/query.py b/gnomemusic/query.py
index 755511c6..774db208 100644
--- a/gnomemusic/query.py
+++ b/gnomemusic/query.py
@@ -559,9 +559,7 @@ class Query():
?playlist
a nmm:Playlist ;
a nfo:MediaList ;
- nfo:hasMediaFileListEntry ?removed_entry .
- ?removed_entry
- nfo:listPosition ?removed_position .
+ nfo:hasMediaFileListEntry/nfo:listPosition ?removed_position .
FILTER (
tracker:id(?playlist) = %(playlist_id)s &&
tracker:id(?removed_entry) = %(song_id)s
@@ -649,8 +647,7 @@ class Query():
query = """
?playlist
a nmm:Playlist ;
- nao:hasTag ?tag .
- ?tag rdfs:comment ?tag_text .
+ nao:hasTag/rdfs:comment ?tag_text .
FILTER ( ?tag_text = '%(playlist_tag)s' )
""".replace('\n', ' ').strip() % {'playlist_tag': playlist_tag}
@@ -714,8 +711,7 @@ class Query():
WHERE {
?song a nmm:MusicPiece ;
nie:usageCounter ?count ;
- nie:isStoredAs ?as .
- ?as nie:url ?url .
+ nie:isStoredAs/nie:url ?url .
FILTER ( STRSTARTS(?url, '%(music_dir)s') )
} ORDER BY DESC(?count) LIMIT 50
""".replace('\n', ' ').strip() % {
@@ -730,8 +726,7 @@ class Query():
SELECT ?url
WHERE {
?song a nmm:MusicPiece ;
- nie:isStoredAs ?as .
- ?as nie:url ?url .
+ nie:isStoredAs/nie:url ?url .
FILTER ( NOT EXISTS { ?song nie:usageCounter ?count .}
&& STRSTARTS(?url, '%(music_dir)s') )
} ORDER BY nfo:fileLastAccessed(?song) LIMIT 50
@@ -755,9 +750,8 @@ class Query():
SELECT ?url
WHERE {
?song a nmm:MusicPiece ;
- nie:isStoredAs ?as ;
+ nie:isStoredAs/nie:url ?url ;
nie:contentAccessed ?last_played .
- ?as nie:url ?url .
FILTER ( ?last_played > '%(compare_date)s'^^xsd:dateTime
&& EXISTS { ?song nie:usageCounter ?count .}
&& STRSTARTS(?url, '%(music_dir)s') )
@@ -784,9 +778,8 @@ class Query():
SELECT ?url
WHERE {
?song a nmm:MusicPiece ;
- nie:isStoredAs ?as ;
+ nie:isStoredAs/nie:url ?url ;
tracker:added ?added .
- ?as nie:url ?url .
FILTER ( ?added > '%(compare_date)s'^^xsd:dateTime
&& STRSTARTS(?url, '%(music_dir)s') )
} ORDER BY DESC(?added) LIMIT 50
@@ -803,9 +796,8 @@ class Query():
SELECT ?url
WHERE {
?song a nmm:MusicPiece ;
- nie:isStoredAs ?as ;
+ nie:isStoredAs/nie:url ?url ;
nao:hasTag nao:predefined-tag-favorite .
- ?as nie:url ?url .
FILTER ( STRSTARTS(?url, '%(music_dir)s') )
} ORDER BY DESC(tracker:added(?song))
""".replace('\n', ' ').strip() % {
@@ -863,8 +855,7 @@ class Query():
def get_albums_with_composer_match(name):
name = Tracker.sparql_escape_string(name)
query = """
- ?song nmm:composer ?composer .
- ?composer fts:match '"nmm:artistName" : %(name)s*' .
+ ?song nmm:composer/fts:match '"nmm:artistName" : %(name)s*' .
""".replace('\n', ' ').strip() % {
'name': name
}
@@ -925,8 +916,7 @@ class Query():
def get_artists_with_composer_match(name):
name = Tracker.sparql_escape_string(name)
query = """
- ?song nmm:composer ?composer .
- ?composer fts:match '"nmm:artistName" : %(name)s*' .
+ ?song nmm:composer/fts:match '"nmm:artistName" : %(name)s*' .
""".replace('\n', ' ').strip() % {
'name': name
}
@@ -972,21 +962,21 @@ class Query():
@staticmethod
def get_songs_with_artist_match(name):
name = Tracker.sparql_escape_string(name)
- query = """?song nmm:performer [ fts:match '%(name)s*' ] . """.replace('\n',' ').strip() % {'name':
name}
+ query = """?song nmm:performer/fts:match '%(name)s*' . """.replace('\n',' ').strip() % {'name': name}
return Query.songs(query)
@staticmethod
def get_songs_with_album_match(name):
name = Tracker.sparql_escape_string(name)
- query = """?song nmm:musicAlbum [ fts:match '%(name)s*' ] . """.replace('\n', ' ').strip() %
{'name': name}
+ query = """?song nmm:musicAlbum/fts:match '%(name)s*' . """.replace('\n', ' ').strip() % {'name':
name}
return Query.songs(query)
@staticmethod
def get_songs_with_composer_match(name):
name = Tracker.sparql_escape_string(name)
- query = """?song nmm:composer [ fts:match '%(name)s*' ] . """.replace('\n', ' ').strip() % {'name':
name}
+ query = """?song nmm:composer/fts:match '%(name)s*' . """.replace('\n', ' ').strip() % {'name': name}
return Query.songs(query)
diff --git a/meson.build b/meson.build
index 0bb190d5..5af3fa9d 100644
--- a/meson.build
+++ b/meson.build
@@ -42,7 +42,7 @@ dependency('gtk+-3.0', version: '>= 3.23.1')
dependency('libdazzle-1.0', version: '>= 3.28.0')
dependency('libmediaart-2.0', version: '>= 1.9.1')
dependency('libsoup-2.4')
-dependency('tracker-sparql-2.0', version: '>= 1.99.1')
+dependency('tracker-sparql-2.0', version: '>= 2.2.0')
dependency('pygobject-3.0', version: '>= 3.29.1')
dependency('py3cairo', version: '>= 1.14.0')
dependency('grilo-0.3', version: '>= 0.3.4')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]