Page MenuHomePhabricator

Expose "PageQuality" to API action=edit
Closed, DuplicatePublic

Description

From IRC

[15:15:51] <shrini> hello all
[15:16:08] <shrini> I am trying to use api to edit wiki pages
[15:16:23] <shrini> in wikisource for tamil language
[15:16:33] <shrini> I can do all the basic edits
[15:16:53] <shrini> but this wikisource has some special form based buttons to mention the edit status
[15:16:55] <shrini> https://snag.gy/f3aTBn.jpg
[15:17:01] <shrini> see here for a screenshots
[15:17:14] <shrini> how to click those buttons via api ?

They were talking about

<span id="wpQuality-container"><span class="quality0"><input tabindex="5" title="Without text" type="radio" value="0" name="wpQuality"></span><span class="quality2"><input tabindex="6" title="Problematic" type="radio" value="2" name="wpQuality"></span><span class="quality1"><input tabindex="7" title="Not proofread" checked="" type="radio" value="1" name="wpQuality"></span><span class="quality3"><input tabindex="8" title="Proofread" type="radio" value="3" name="wpQuality"></span></span>

Event Timeline

Tpt subscribed.

Duplicates of T30894.

The current way to do it is to call action=query&prop=revision to get the Page: page content in JSON
https://en.wikisource.org/w/api.php?action=query&prop=revisions&titles=Page%3APopular_Science_Monthly_Volume_54.djvu%2F434&rvprop=content&rvcontentformat=application%2Fjson

Then modify the level.level field and set level.user to your user name and publish the modify content using action=edit and setting contentformat=application/json

Add: its need to fix another option of API to Action=edit, Header Footer, Page body separately to resolved our one issue of Google OCR Script.

@Tpt Need help on forming the api fir edit action.

I get the following error

{

"servedby": "mw1134",
"error": {
    "code": "internal_api_error_MWContentSerializationException",
    "info": "[VyEt3gpAEHIAAC3ySf4AAABO] Exception Caught: The serialization is an invalid JSON array."
}

}

Testing with following url.

https://en.wikisource.org/wiki/Special:ApiSandbox#action=edit&format=json&title=test.pdf%2F500&text=article+content&summary=test+summary&tags=&basetimestamp=2007-08-24T12%3A34%3A54.000Z&contentformat=application%2Fjson&contentmodel=proofread-page&token=55871aa0c7e3c953841e3d5ecbed3e8557212db0%2B\

Simple edit query without the level and user info is giving serialization error. Not sure on how to add the level and user details.

Will be so helpful if you give the working example with level, user info set for edit api.

Thanks.

payload = {'action': 'edit', 'contentformat':'application/json', 'utf8': '', 'appendtext': page_body,'summary': summary, 'title': title, 'token': token, 'contentmodel':'proofread-page','level':{'level':2,'user':wiki_username}}

page = wiki.call(payload)

Calling like this in python using simplemediawiki module.

This gives error as

{u'edit': {u'contentmodel': u'proofread-page',

u'nochange': u'',
u'pageid': 404589,
u'result': u'Success',
u'title': u'Page:\u0b95\u0bc1\u0bb1\u0bbf\u0b9e\u0bcd\u0b9a\u0bbf \u0bae\u0bb2\u0bb0\u0bcd.pdf/500'},

u'warnings': {u'main': {u'*': u"Unrecognized parameter: 'level'"}}}

Need help on setting this json witl level parameter.

Thanks.

You shouldn't use the "appendtext" parameter and use the "text" parameter that should be a serialization of this JSON tree:

{
  "header": THE_PAGE_HEADER,
  "body": THE_PAGE BODY,
  "footer": THE_PAGE_FOOTER,
  "level": {
     "level": THE_PROOFREADING_LEVEL,
     "user": THE_PROOFREADING_USER
  }
}

with:
THE_PAGE_HEADER the header (probably just "")
THE_PAGE_BODY the body (probably the OCR output)
THE_PAGE_FOOTER the footer (probably something like "<references />"
THE_PROOFREADING_LEVEL the proofreading level (an integer between 0 and 4 with 0: page without text, 1: not proofread, 2: probablematic, 3: proofread, 4: validated). You will probably use 1
THE_PROOFREADING_USER the user who have asserted this proofreading user. Should be the user doing the edit

Thanks @Tpt

For the following code,

payload = {'action': 'edit', 'contentformat':'application/json', 'utf8': '', 'body': page_body,'summary': summary, 'title': title, 'token': token, 'contentmodel':'proofread-page','level':{'level':2,'user':wiki_username}}

page = wiki.call(payload)

getting error as

{u'error': {u'*': u'See https://ta.wikisource.org/w/api.php for API usage',

u'code': u'notext',
u'info': u'One of the text, appendtext, prependtext and undo parameters must be set'},

Do I miss to add something?

Thanks.

page = wiki.call(payload) didnt set text=....

Try page = wiki.call(text=payload).

If that doesnt work, file a support request with your python library.