Skip to content

Instantly share code, notes, and snippets.

@kartben
Last active July 4, 2019 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartben/350a9b72374e44c8ab60abaaef7c1acd to your computer and use it in GitHub Desktop.
Save kartben/350a9b72374e44c8ab60abaaef7c1acd to your computer and use it in GitHub Desktop.
list of famous paintings + thumbnails
SELECT ?item ?itemLabel ?thumb ?catcode WHERE { ?item p:P528 [ pq:P972 wd:Q41634361 ; ps:P528 ?catcode].
?item wdt:P18 ?picture .
BIND(REPLACE(wikibase:decodeUri(STR(?picture)), "http://commons.wikimedia.org/wiki/Special:FilePath/", "") as ?fileName) .
BIND(REPLACE(?fileName, " ", "_") as ?safeFileName)
BIND(MD5(?safeFileName) as ?fileNameMD5) .
BIND(CONCAT("https://upload.wikimedia.org/wikipedia/commons/thumb/", SUBSTR(?fileNameMD5, 1, 1), "/", SUBSTR(?fileNameMD5, 1, 2), "/", ?safeFileName, "/650px-", ?safeFileName) as ?thumb)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
} ORDER BY xsd:integer(?catcode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment