On Fri, 15 Nov 2013 09:37:49 +0100, Thomas <thomas(a)thomaszander.se> wrote:
I use the API to fetch some metadata;
en.wikipedia.org/w/api.php?action=query&prop=imageinfo \
&iilimit=1&format=xml&iiprop=dimensions%7Cmime&titles=[foo]
The piece of the puzzle I am still missing is how to find out the actual download URL for
any given image.
Just add "url" to "iiprop" and the API will return the full URL.
I've seen images start with;
http://upload.wikimedia.org/wikipedia/en/6/6d/
and with;
http://upload.wikimedia.org/wikipedia/commons/d/d0/
But I don't really understand how to decide what url to prefix to my image-name.
Anyone can shed some light on this?
The "wikipedia/en" / "wikipedia/commons" part depends on which wiki
the file is uploaded to, in these cases the English Wikipedia or Wikimedia Commons (which
is a repository of media files used by all Wikipedias and sister projects in all
languages).
The "6/6d" / "d/d0" part is constructed based on the MD5 hash of the
filename, for example md5("Wiki.png") == bc32c4ef985f1924664e5f5c7359ef62, so
the URL is
https://upload.wikimedia.org/wikipedia/en/b/bc/Wiki.png . But I wouldn't
rely on that, especially if you're already calling the API.
--
Matma Rex