All pastes #2081660 Raw Edit

Stuff

public python v1 · immutable
#2081660 ·published 2011-09-20 21:40 UTC
rendered paste body
# Get video mimetypes that Phonon can play :mimetypes = Phonon.BackendCapabilities.availableMimeTypes()# Transform the list of available mimeTypes into a Nepomuk.Query.OrTerm :mimeTypesTerms = [Nepomuk.Query.LiteralTerm(Soprano.LiteralValue(m)) for m in mimeTypes if m.startsWith('video')]orTerm = Nepomuk.Query.OrTerm(mimeTypesTerms)# Get the Nepomuk property for mimeType :prop = Nepomuk.Types.Property(KUrl('http://www.semanticdesktop.org/ontologies/2007/01/19/nie/#mimeType'))# Build the ComparisonTerm :comparisonTerm = Nepomuk.Query.ComparisonTerm(prop, orTerm)# Build the Query :query = Nepomuk.Query.FileQuery(comparisonTerm)query.setFileMode(Nepomuk.Query.FileQuery.QueryFiles)# Sets where to look for files :sources = ["/home/user/movies/", "/media/share/movies/"]for s in sources:    query.addIncludeFolder(KUrl(s), True)model.dirLister().openUrl(query.toSearchUrl())####################query.toSparqlQuery() :select distinct ?r (bif:concat(bif:search_excerpt(bif:vector('video/x-flic'), ?v56),bif:search_excerpt(bif:vector('video/quicktime'), ?v32),bif:search_excerpt(bif:vector('video/x-quicktime'), ?v36),bif:search_excerpt(bif:vector('video/x-ms-wmv'), ?v80),bif:search_excerpt(bif:vector('video/mkv'), ?v12),bif:search_excerpt(bif:vector('video/annodex'), ?v4),bif:search_excerpt(bif:vector('video/x-ms-asf-plugin'), ?v84),bif:search_excerpt(bif:vector('video/x-flv'), ?v100),bif:search_excerpt(bif:vector('video/x-matroska'), ?v16),bif:search_excerpt(bif:vector('video/x-anim'), ?v60),bif:search_excerpt(bif:vector('video/x-annodex'), ?v8),bif:search_excerpt(bif:vector('video/x-ms-wvx'), ?v88),bif:search_excerpt(bif:vector('video/flv'), ?v104),bif:search_excerpt(bif:vector('video/anim'), ?v64),bif:search_excerpt(bif:vector('video/mp4'), ?v40),bif:search_excerpt(bif:vector('video/mpeg'), ?v108),bif:search_excerpt(bif:vector('video/ogg'), ?v68),bif:search_excerpt(bif:vector('video/mp2t'), ?v44),bif:search_excerpt(bif:vector('video/webm'), ?v20),bif:search_excerpt(bif:vector('video/mng'), ?v48),bif:search_excerpt(bif:vector('video/x-ms-wax'), ?v92),bif:search_excerpt(bif:vector('video/msvideo'), ?v24),bif:search_excerpt(bif:vector('video/mp2p'), ?v96),bif:search_excerpt(bif:vector('video/x-mpeg'), ?v112),bif:search_excerpt(bif:vector('video/x-msvideo'), ?v28),bif:search_excerpt(bif:vector('video/x-ogg'), ?v72),bif:search_excerpt(bif:vector('video/x-ms-asf'), ?v76),bif:search_excerpt(bif:vector('video/x-mng'), ?v52))) as ?_n_f_t_m_ex_ where {     {         {             {                 ?r ?v2 ?v4 .                 FILTER(bif:contains(?v4, "'video/annodex'")) .             }             UNION {                 ?r ?v2 ?v5 .                 ?v5 ?v3 ?v4 .                 ?v3 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v4, "'video/annodex'")) .             }  .         }         UNION {             {                 ?r ?v6 ?v8 .                 FILTER(bif:contains(?v8, "'video/x-annodex'")) .             }             UNION {                 ?r ?v6 ?v9 .                 ?v9 ?v7 ?v8 .                 ?v7 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v8, "'video/x-annodex'")) .             }  .         }         UNION {             {                 ?r ?v10 ?v12 .                 FILTER(bif:contains(?v12, "'video/mkv'")) .             }             UNION {                 ?r ?v10 ?v13 .                 ?v13 ?v11 ?v12 .                 ?v11 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v12, "'video/mkv'")) .             }  .         }         UNION {             {                 ?r ?v14 ?v16 .                 FILTER(bif:contains(?v16, "'video/x-matroska'")) .             }             UNION {                 ?r ?v14 ?v17 .                 ?v17 ?v15 ?v16 .                 ?v15 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v16, "'video/x-matroska'")) .             }  .         }         UNION {             {                 ?r ?v18 ?v20 .                 FILTER(bif:contains(?v20, "'video/webm'")) .             }             UNION {                 ?r ?v18 ?v21 .                 ?v21 ?v19 ?v20 .                 ?v19 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v20, "'video/webm'")) .             }  .         }         UNION {             {                 ?r ?v22 ?v24 .                 FILTER(bif:contains(?v24, "'video/msvideo'")) .             }             UNION {                 ?r ?v22 ?v25 .                 ?v25 ?v23 ?v24 .                 ?v23 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v24, "'video/msvideo'")) .             }  .         }         UNION {             {                 ?r ?v26 ?v28 .                 FILTER(bif:contains(?v28, "'video/x-msvideo'")) .             }             UNION {                 ?r ?v26 ?v29 .                 ?v29 ?v27 ?v28 .                 ?v27 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v28, "'video/x-msvideo'")) .             }  .         }         UNION {             {                 ?r ?v30 ?v32 .                 FILTER(bif:contains(?v32, "'video/quicktime'")) .             }             UNION {                 ?r ?v30 ?v33 .                 ?v33 ?v31 ?v32 .                 ?v31 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v32, "'video/quicktime'")) .             }  .         }         UNION {             {                 ?r ?v34 ?v36 .                 FILTER(bif:contains(?v36, "'video/x-quicktime'")) .             }             UNION {                 ?r ?v34 ?v37 .                 ?v37 ?v35 ?v36 .                 ?v35 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v36, "'video/x-quicktime'")) .             }  .         }         UNION {             {                 ?r ?v38 ?v40 .                 FILTER(bif:contains(?v40, "'video/mp4'")) .             }             UNION {                 ?r ?v38 ?v41 .                 ?v41 ?v39 ?v40 .                 ?v39 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v40, "'video/mp4'")) .             }  .         }         UNION {             {                 ?r ?v42 ?v44 .                 FILTER(bif:contains(?v44, "'video/mp2t'")) .             }             UNION {                 ?r ?v42 ?v45 .                 ?v45 ?v43 ?v44 .                 ?v43 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v44, "'video/mp2t'")) .             }  .         }         UNION {             {                 ?r ?v46 ?v48 .                 FILTER(bif:contains(?v48, "'video/mng'")) .             }             UNION {                 ?r ?v46 ?v49 .                 ?v49 ?v47 ?v48 .                 ?v47 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v48, "'video/mng'")) .             }  .         }         UNION {             {                 ?r ?v50 ?v52 .                 FILTER(bif:contains(?v52, "'video/x-mng'")) .             }             UNION {                 ?r ?v50 ?v53 .                 ?v53 ?v51 ?v52 .                 ?v51 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v52, "'video/x-mng'")) .             }  .         }         UNION {             {                 ?r ?v54 ?v56 .                 FILTER(bif:contains(?v56, "'video/x-flic'")) .             }             UNION {                 ?r ?v54 ?v57 .                 ?v57 ?v55 ?v56 .                 ?v55 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v56, "'video/x-flic'")) .             }  .         }         UNION {             {                 ?r ?v58 ?v60 .                 FILTER(bif:contains(?v60, "'video/x-anim'")) .             }             UNION {                 ?r ?v58 ?v61 .                 ?v61 ?v59 ?v60 .                 ?v59 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v60, "'video/x-anim'")) .             }  .         }         UNION {             {                 ?r ?v62 ?v64 .                 FILTER(bif:contains(?v64, "'video/anim'")) .             }             UNION {                 ?r ?v62 ?v65 .                 ?v65 ?v63 ?v64 .                 ?v63 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v64, "'video/anim'")) .             }  .         }         UNION {             {                 ?r ?v66 ?v68 .                 FILTER(bif:contains(?v68, "'video/ogg'")) .             }             UNION {                 ?r ?v66 ?v69 .                 ?v69 ?v67 ?v68 .                 ?v67 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v68, "'video/ogg'")) .             }  .         }         UNION {             {                 ?r ?v70 ?v72 .                 FILTER(bif:contains(?v72, "'video/x-ogg'")) .             }             UNION {                 ?r ?v70 ?v73 .                 ?v73 ?v71 ?v72 .                 ?v71 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v72, "'video/x-ogg'")) .             }  .         }         UNION {             {                 ?r ?v74 ?v76 .                 FILTER(bif:contains(?v76, "'video/x-ms-asf'")) .             }             UNION {                 ?r ?v74 ?v77 .                 ?v77 ?v75 ?v76 .                 ?v75 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v76, "'video/x-ms-asf'")) .             }  .         }         UNION {             {                 ?r ?v78 ?v80 .                 FILTER(bif:contains(?v80, "'video/x-ms-wmv'")) .             }             UNION {                 ?r ?v78 ?v81 .                 ?v81 ?v79 ?v80 .                 ?v79 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v80, "'video/x-ms-wmv'")) .             }  .         }         UNION {             {                 ?r ?v82 ?v84 .                 FILTER(bif:contains(?v84, "'video/x-ms-asf-plugin'")) .             }             UNION {                 ?r ?v82 ?v85 .                 ?v85 ?v83 ?v84 .                 ?v83 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v84, "'video/x-ms-asf-plugin'")) .             }  .         }         UNION {             {                 ?r ?v86 ?v88 .                 FILTER(bif:contains(?v88, "'video/x-ms-wvx'")) .             }             UNION {                 ?r ?v86 ?v89 .                 ?v89 ?v87 ?v88 .                 ?v87 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v88, "'video/x-ms-wvx'")) .             }  .         }         UNION {             {                 ?r ?v90 ?v92 .                 FILTER(bif:contains(?v92, "'video/x-ms-wax'")) .             }             UNION {                 ?r ?v90 ?v93 .                 ?v93 ?v91 ?v92 .                 ?v91 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v92, "'video/x-ms-wax'")) .             }  .         }         UNION {             {                 ?r ?v94 ?v96 .                 FILTER(bif:contains(?v96, "'video/mp2p'")) .             }             UNION {                 ?r ?v94 ?v97 .                 ?v97 ?v95 ?v96 .                 ?v95 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v96, "'video/mp2p'")) .             }  .         }         UNION {             {                 ?r ?v98 ?v100 .                 FILTER(bif:contains(?v100, "'video/x-flv'")) .             }             UNION {                 ?r ?v98 ?v101 .                 ?v101 ?v99 ?v100 .                 ?v99 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v100, "'video/x-flv'")) .             }  .         }         UNION {             {                 ?r ?v102 ?v104 .                 FILTER(bif:contains(?v104, "'video/flv'")) .             }             UNION {                 ?r ?v102 ?v105 .                 ?v105 ?v103 ?v104 .                 ?v103 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v104, "'video/flv'")) .             }  .         }         UNION {             {                 ?r ?v106 ?v108 .                 FILTER(bif:contains(?v108, "'video/mpeg'")) .             }             UNION {                 ?r ?v106 ?v109 .                 ?v109 ?v107 ?v108 .                 ?v107 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v108, "'video/mpeg'")) .             }  .         }         UNION {             {                 ?r ?v110 ?v112 .                 FILTER(bif:contains(?v112, "'video/x-mpeg'")) .             }             UNION {                 ?r ?v110 ?v113 .                 ?v113 ?v111 ?v112 .                 ?v111 <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <http://www.w3.org/2000/01/rdf-schema#label> .                 FILTER(bif:contains(?v112, "'video/x-mpeg'")) .             }  .         }  .         ?r a <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject> .         FILTER(!bif:exists((select (1) where {             ?r a <http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Folder> .         }        ))) .         ?r <http://www.semanticdesktop.org/ontologies/2007/01/19/nie#url> ?v114 .         FILTER(REGEX(STR(?v114), '(^file:///home/francois/Films/)', 'i')) .     }  .     ?r <http://www.semanticdesktop.org/ontologies/2007/08/15/nao#userVisible> ?v1 .     FILTER(?v1>0) . }