Hi all.
I am developing a set of Ruby libraries for Wikipedia/MediaWiki access:
* low-level: https://github.com/molybdenum-99/mediawiktory * high-level (semantic): https://github.com/molybdenum-99/infoboxer
I have a problem with understanding some files. For example, this one: https://en.wikipedia.org/wiki/File:Logo_of_the_Verkhovna_Rada_of_Ukraine.svg
In UI, the page states the file is actually on commons, but the page itself exists and is accessible.
In API: https://en.wikipedia.org/w/api.php?action=query&titles=File:Logo_of_the_... -- it is "completely absent" like it is missing totally. In Commons API it is there OK: https://commons.wikimedia.org/w/api.php?action=query&titles=File:Logo_of...
Is there a way to tell actually non-existent files from files that are included from commons, through API? Or "just check on commons, in case it is there" is the only way?
Thanks in advance.
V.
On Fri, Jan 26, 2018 at 9:16 AM, Victor Shepelev zverok.offline@gmail.com wrote:
Is there a way to tell actually non-existent files from files that are included from commons, through API?
Use prop=imageinfo and look at the "imagerepository". If it's not the empty string, the image exists. If it's "local" then the image exists locally. Otherwise, it's on a foreign repo such as Commons. On any WMF wiki except test2wiki, Commons (with the value "shared") is currently the only non-local possibility.
https://en.wikipedia.org/w/api.php?action=query&titles=File:Logo_of_the_...
On 2018-01-26 09:16, Victor Shepelev wrote:
Is there a way to tell actually non-existent files from files that are included from commons, through API? Or "just check on commons, in case it is there" is the only way?
You can add &prop=imageinfo to the query:
Files that are loaded from Commons will have the property `"imagerepository": "shared"`: https://en.wikipedia.org/w/api.php?action=query&titles=File:Logo_of_the_...
Files that are uploaded locally will have `"imagerepository": "local"`: https://en.wikipedia.org/w/api.php?action=query&titles=File:Example.jpg&...
Files that are actually missing will have `"imagerepository": ""`: https://en.wikipedia.org/w/api.php?action=query&titles=File:Does%20not%2...
prop=imageinfo also provides some other information about the files, if you add additional options. See https://www.mediawiki.org/wiki/API:Imageinfo .
Awesome, thanks! I was not expecting that something with missing: true will fetch any properties. But it makes sense now.
2018-01-26 19:29 GMT+02:00 Bartosz Dziewoński matma.rex@gmail.com:
On 2018-01-26 09:16, Victor Shepelev wrote:
Is there a way to tell actually non-existent files from files that are included from commons, through API? Or "just check on commons, in case it is there" is the only way?
You can add &prop=imageinfo to the query:
Files that are loaded from Commons will have the property `"imagerepository": "shared"`: https://en.wikipedia.org/w/api.php?action=query&titles=File: Logo_of_the_Verkhovna_Rada_of_Ukraine.svg&prop=imageinfo
Files that are uploaded locally will have `"imagerepository": "local"`: https://en.wikipedia.org/w/api.php?action=query&titles=File: Example.jpg&prop=imageinfo
Files that are actually missing will have `"imagerepository": ""`: https://en.wikipedia.org/w/api.php?action=query&titles=File: Does%20not%20exist%20blahblahblah.svg&prop=imageinfo
prop=imageinfo also provides some other information about the files, if you add additional options. See https://www.mediawiki.org/wiki /API:Imageinfo .
-- Bartosz Dziewoński
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
mediawiki-api@lists.wikimedia.org