Files moved to Commons

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Files moved to Commons

Victor Shepelev
Hi all.

I am developing a set of Ruby libraries for Wikipedia/MediaWiki access:


I have a problem with understanding some files.

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_Verkhovna_Rada_of_Ukraine.svg -- it is "completely absent" like it is missing totally. 

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.

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Files moved to Commons

Brad Jorsch (Anomie)
On Fri, Jan 26, 2018 at 9:16 AM, Victor Shepelev
<[hidden email]> 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_Verkhovna_Rada_of_Ukraine.svg&prop=imageinfo


--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Files moved to Commons

Bartosz Dziewoński
In reply to this post by Victor Shepelev
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
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Files moved to Commons

Victor Shepelev
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 <[hidden email]>:
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
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api


_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api