Page MenuHomePhabricator

Implement file captions in Pywikibot
Closed, ResolvedPublic

Description

We would like to have the feature of file captions, part of StructuredDataOnCommons, implemented in Pywikibot in order to use Pywikibot for mass uploads.

Event Timeline

Xqt triaged this task as Low priority.Jan 21 2019, 4:19 PM

Currently we can retrieve caption entries only but not write it. I think this doesn't help for T203010 currently. Seems we have to wait for further api implementations.

Currently we can retrieve caption entries only but not write it. I think this doesn't help for T203010 currently. Seems we have to wait for further api implementations.

Correct me if I’m wrong, but I believe that you can already write captions using wbsetlabel − although, as I understand it, would be an additional API call using the media ID (which is derived from the page_id, which I presume also needs to be retrieved post-upload via an API call).

(Poking @Addshore to correct me if I’m wrong above.)

(In case this can be useful for inspiration: the implementation in UploadWizard was tracked in T188502 and the bulk of it done in feee3d4f819d.)

Correct me if I’m wrong, but I believe that you can already write captions using wbsetlabel − although, as I understand it, would be an additional API call using the media ID (which is derived from the page_id, which I presume also needs to be retrieved post-upload via an API call).

That is indeed correct

Change 627243 had a related patch set uploaded (by Matěj Suchánek; owner: Matěj Suchánek):
[pywikibot/core@master] [FEAT] Minimal working example for Structured data on Commons

https://gerrit.wikimedia.org/r/627243

Change 627243 merged by jenkins-bot:

[pywikibot/core@master] [FEAT] Minimal working example for Structured data on Commons

https://gerrit.wikimedia.org/r/627243

import pywikibot

file_repo = pywikibot.Site('commons', 'commons')
file_page = pywikibot.FilePage(file_repo, 'Würfelzucker_--_2018_--_3564.jpg')
file_item = file_page.data_item()
caption = file_item.labels['en']  # 'Sugar cubes (2018)'