This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

1. Music

1.1. List all files

SELECT ?url
WHERE { 
  ?song a nmm:MusicPiece ;
        nie:isStoredAs ?as .
  ?as nie:url ?url .
}

1.2. List all files and their properties

This uses the OPTIONAL SPARQL keyword. This means that the data may or may not exist. Without this, results are not listed if it is just requested.

SELECT * 
WHERE {
  ?song a nmm:MusicPiece ;
        nie:title ?title ;
        nmm:performer [ nmm:artistName ?performer ] ;
        nmm:musicAlbum [ nie:title ?album ] .
  OPTIONAL { 
    ?song nmm:genre ?genre 
  } .
  OPTIONAL { 
    ?song nmm:trackNumber ?track 
  } .
  OPTIONAL { 
    ?song nmm:composer [ nmm:artistName ?composer ] 
  }
}

1.3. List all albums

This query includes the number of songs and total duration of the music:

SELECT ?album ?title COUNT(?song) AS songs SUM(?length) AS totallength 
WHERE {
  ?album a nmm:MusicAlbum ;
           nie:title ?title .
  ?song nmm:musicAlbum ?album ;
        nmm:length ?length
} 
GROUP BY ?album

1.4. List all album and artist combinations

SELECT ?album ?performer ?url
WHERE {
  ?song nmm:musicAlbum ?album ; 
        nmm:performer ?performer ;
        nie:isStoredAs ?as .
  ?as nie:url ?url .
} GROUP BY ?album ?performer

1.5. List everything from a single artist

SELECT ?song ?title ?url
WHERE {
  ?song nmm:performer [ nmm:artistName 'Artist Name' ] ;
        nie:title ?title ;
        nie:isStoredAs ?as .
  ?as nie:url ?url .
}

1.6. List all artists, album count, song count and total song duration

SELECT ?performer COUNT(?album) AS albumcount SUM(?length) AS totallength 
WHERE {
  ?song nmm:performer ?performer ;
        nmm:length ?length ;
        nmm:musicAlbum ?album
} GROUP BY ?performer

1.7. Set last played to a item

DELETE {
  ?unknown nie:contentAccessed ?time
} WHERE {
  ?unknown nie:contentAccessed ?time ;
           nie:isStoredAs ?as .
  ?as nie:url 'file:///home/user/Music/song.mp3' .
}
INSERT {
  ?unknown nie:contentAccessed '2009-05-15T11:30:00' ;
} WHERE {
  ?unknown nie:contentAccessed ?time ;
           nie:isStoredAs ?as .
  ?as nie:url 'file:///home/user/Music/song.mp3' .
}

1.8. Set play count of a song

DELETE {
  ?unknown nie:usageCounter ?count
} WHERE {
  ?unknown nie:usageCounter ?count ;
           nie:isStoredAs ?as .
  ?as nie:url 'file:///home/user/Music/song.mp3' .
}
INSERT {
  ?unknown nie:usageCounter 42
} WHERE {
  ?unknown nie:contentAccessed ?time ;
           nie:isStoredAs ?as .
  ?as nie:url 'file:///home/user/Music/song.mp3' .
}

1.9. List most listened songs

SELECT ?song ?title ?count ?url
WHERE {
  ?song nie:usageCounter ?count ;
        nie:title ?title ;
        nie:isStoredAs ?as .
  ?as nie:url ?url .
} ORDER BY DESC(?count) LIMIT 10

1.10. List most recently listened to songs

SELECT ?song ?title ?time ?url
WHERE {
  ?song nie:contentAccessed ?time ;
        nie:title ?title ;
        nie:isStoredAs ?as .
  ?as nie:url ?url .
} ORDER BY DESC(?time) LIMIT 10


2024-10-23 10:59