query-97693c45e43e739a568da683ab4ca38b
EpicPupper(P18)image
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX schema: <http://schema.org/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?P18_value ?filename ?contentUrl
WHERE
{
SERVICE <https://query.wikidata.org/sparql>
{
SERVICE bd:slice
{
[] ps:P18 ?P18_value .
bd:serviceParam bd:slice.offset 0 .
bd:serviceParam bd:slice.limit 10000 .
}
BIND (REPLACE(SUBSTR(wikibase:decodeUri(STR(?P18_value)), 52), " ", "_") AS ?filename)
BIND (MD5(?filename) AS ?MD5)
BIND (URI(CONCAT("https://upload.wikimedia.org/wikipedia/commons/",
SUBSTR(?MD5, 1, 1), "/",
SUBSTR(?MD5, 1, 2), "/", ENCODE_FOR_URI(?filename)
)
) AS ?contentUrl)
}
FILTER NOT EXISTS { ?file schema:contentUrl ?contentUrl . }
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v5("?MD5")
v3("?P18_value"):::projected
v6("?contentUrl"):::projected
v1("?file")
v4("?filename"):::projected
a1((" "))
c7(["0^^xsd:integer"]):::literal
c5(["bd:serviceParam"]):::iri
c9(["10000^^xsd:integer"]):::literal
f0[["not "]]
subgraph f0e0["Exists Clause"]
e0v1 --"schema:contentUrl"--> e0v2
e0v2("?contentUrl"):::projected
e0v1("?file"):::projected
end
f0--EXISTS--> f0e0
f0 --> v1
f0 --> c1
f0 --> v6
v1 --"schema:contentUrl"--> v6
subgraph s1["https://query.wikidata.org/sparql"]
style s1 stroke-width:4px;
subgraph s2["http://www.bigdata.com/rdf#slice"]
style s2 stroke-width:4px;
a1 --"ps:P18"--> v3
c5 --"bd:slice.offset"--> c7
c5 --"bd:slice.limit"--> c9
end
bind1[/"replace(substring(http://wikiba.se/ontology#decodeUri(str(?P18_value)),'52^^xsd:integer'),' ','_')"/]
v3 --o bind1
bind1 --as--o v4
bind2[/"MD5(?filename)"/]
v4 --o bind2
bind2 --as--o v5
bind3[/"concat('https://upload.wikimedia.org/wikipedia/commons/',substring(?MD5,'1^^xsd:integer','1^^xsd:integer'),'/',substring(?MD5,'1^^xsd:integer','2^^xsd:integer'),'/',encode-for-uri(?filename))"/]
v5 --o bind3
v4 --o bind3
bind3 --as--o v6
end