GNOME Bugzilla – Bug 740707
tracker: Add range filter support
Last modified: 2015-01-27 17:36:40 UTC
In Videos, we'd like to ignore the smaller videos, for example: grl_operation_options_set_key_range_filters (my_options, GRL_METADATA_KEY_DURATION, 2, NULL, NULL); to ignore videos smaller than 2 seconds.
Hi Bastien, just tested this, it works: """ SELECT ?m nfo:fileName(?m) ?duration WHERE { ?m a nfo:FileDataObject . OPTIONAL { ?m nfo:duration ?duration } . FILTER(?duration > 200 || !BOUND(?duration)) } """ Let me explain what it does: 1. It returns all FILES, you can change the nfo:FileDataObject to nmm:MusicPiece or nfo:Audio depending on what you want here. 2. The OPTIONAL is a LEFT OUTER JOIN in database terms, it's not super performant but it's the only way you can add data that may or may not be there. 3. The FILTER is quite obvious initially, but the !BOUND means that we filter out any cases where duration is not specified. This works with the OPTIONAL because we don't know if ?duration is always available. The BOUND is a SPARQL feature documented here: http://www.w3.org/TR/rdf-sparql-query/#func-bound Happy to help ;)
Finally, I should add, the "200" is 200 seconds, it's just what I tested with because my data was ALL album track length content. You would of course use "2".
Created attachment 291990 [details] [review] tracker: Add duration filtering support Duration filtering support for search and browse. Note that query doesn't add the duration filtering automatically.
Attachment 291990 [details] pushed as 44bf700 - tracker: Add duration filtering support