query-71479bb8c61882144bac8148b920a935

rq turtle/ttl

. Using that info I made this query: mw:Manual:$wgHashedUploadDirectory: Sorry for the delay. I found out how to construct the content URL from the filename. It is explained in Vojtěch Dostál@ ]reply[09:49, 17 November 2020 (UTC)) talk (Vojtěch DostálThank you - I see the discussion. Happy to see that I might not be completely ignorant of something elementary :-). Thank you for inquiring the issue. ]reply[09:44, 17 November 2020 (UTC)) talk (Dipsacus fullonum and thought that I easily could make a query for you. However it turned out that the documentation is wrong, and it seems that there are no triples in WCQS to go from filenames to the media objects (M-numbers). I asked for help yesterday at the documentation talk page at mediawiki.org. If I don't get an answer from the development team today I will try at Phabricator. I will return when I know more. --mw:Extension:WikibaseMediaInfo/RDF mapping: I read the documentation at Vojtěch Dostál@ ]reply[06:46, 16 November 2020 (UTC)) talk (Vojtěch DostálHi! Yeah, sorry, I should have made myself clearer, although the uploader will be the same as creator in most of these cases. Anyway, querying for "creator" would be just fine for this :). Thank you very much, ]reply[22:45, 15 November 2020 (UTC)) talk (Dipsacus fullonum. I think that is possible, but the query you outline will not find the uploader. It will find the creator if they happen to have a Wikimedia username. That may be someone else than the uploader. You can find the uploader for all images by using the MWAPI service to call Commons Mediawiki API although I'm not sure that it is possible for all 6328 images in one query without timeout. So do you want creator or uploader for images? --Vojtěch DostálHi So, Zbyszko suggest to correct the query this way:

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX schema: <http://schema.org/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
SELECT ?username (COUNT(DISTINCT ?file) AS ?count)
WHERE
{

{
  SELECT ?file
  WHERE
  {

{
  SELECT ?item ?image ?filename ?contentUrl
  WHERE
  {
    SERVICE <https://query.wikidata.org/sparql>
    {
      ?item wdt:P31 wd:Q5153359 .
      ?item wdt:P18 ?image .
    }
    BIND (REPLACE(wikibase:decodeUri(SUBSTR(STR(?image), 52)), " ", "_") AS ?filename)
    BIND (REPLACE(SUBSTR(STR(?image), 52), "%20", "_") AS ?filenameUnencoded)
    BIND (MD5(?filename) AS ?MD5)
    BIND (URI(CONCAT("https://upload.wikimedia.org/wikipedia/commons/", SUBSTR(?MD5, 1, 1), "/", SUBSTR(?MD5, 1, 2), "/", ?filenameUnencoded)) As ?contentUrl)
  }
}    ?file schema:contentUrl ?contentUrl .
  }
}  ?file p:P170 / pq:P4174 ?username .
}
GROUP BY ?username

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v5("?MD5") v6("?contentUrl") v9("?count") v7("?file"):::projected v3("?filename") v4("?filenameUnencoded") v2("?image") v1("?item") v8("?username"):::projected a1((" ")) c3(["wd:Q5153359"]):::iri subgraph s1["https://query.wikidata.org/sparql"] style s1 stroke-width:4px; v1 --"p:direct/P31"--> c3 v1 --"p:direct/P18"--> v2 end bind0[/"replace(http://wikiba.se/ontology#decodeUri(substring(str(?image),'52^^xsd:integer')),' ','_')"/] v2 --o bind0 bind0 --as--o v3 bind1[/"replace(substring(str(?image),'52^^xsd:integer'),'%20','_')"/] v2 --o bind1 bind1 --as--o v4 bind2[/"MD5(?filename)"/] v3 --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'),'/',?filenameUnencoded)"/] v5 --o bind3 v4 --o bind3 bind3 --as--o v6 v7 --"schema:contentUrl"--> v6 v7 --"p:P170"--> a1 a1 --"p:qualifier/P4174"--> v8 bind5[/"count(?file)"/] v7 --o bind5 bind5 --as--o v9