User talk:MER-C/Wiki.java

Special page equivalents
See Special:Specialpages for a list of special pages. The text on special pages may be edited by editing the appropriate system message.

Two Errors
Hello, There are two little Errors in your Code:

First:

In the method "getPageText(String title)" the row

should be

second:

the method "login" doesn't work at the german Wikipedia, the Bot log in correctly, but the Function returns false, because in the German Login-page the text "Login successful" doesn't exist.

--88.72.43.131 11:05, 14 November 2007 (UTC) I hope you can understand me. I know, my english isn't very good ;)
 * Fixed both, but it would be some time before they are live - the todo list for 0.10 is quite long. (The fix for the second one is to replace "Login successful" with "wgUserName = \"" + username + "\"", if you can't wait). MER-C 05:50, 16 November 2007 (UTC)

getPageText can use API
— Preceding unsigned comment added by 80.143.120.164 (talk • contribs)

Sorry about the wait - I only check this page when I release a new version. The current way avoids parsing any XML. Sometimes it's harder and slower to use the API - rollback is another example. . (I did, however, tweak the docs to detail what happens when exists(title)[0] == false). MER-C 10:56, 22 August 2008 (UTC)
 * I'm having second thoughts about WONTFIXing this, the API's resolve redirects functionality could be handy here. MER-C 12:55, 22 August 2008 (UTC)

using rights and not groups for "apihighlimits"
Use rights to chance highlimit, not group ('BOT' or 'ADMIN' are groups see 'query("meta=userinfo&uiprop=rights|groups")', but you call it right ('User.userRights')


 * This adds a query for no real reason because the result of User.userRights is cached. (Just tweak the source if the default doesn't apply to you.) The method is named after Special:Userrights before I realized they were groups. Implementing the whole permissions model would result in lots of public static final long (ints aren't good enough) spam and take 500+ lines. . MER-C 14:01, 23 August 2008 (UTC)

Upload bug?
Hi, I'm trying your code (great BTW) to upload files. There seems to be a problem with "special" chars in the destination filename and the description (see for example http://commons.wikimedia.org/wiki/File:Test%2Bkgoiyfyktgkggukgku.jpg): I tried to add "Content-Type:text/plain; charset=utf-8;" to the upload description and/or the wpDestFile (both with and without the content-type), but no luck. Do you know a quick fix? Cheers, --Magnus Manske (talk) 23:34, 7 August 2009 (UTC)
 * Spaces in the dest filename will turn into "+"
 * Upload will say "Successfully uploaded" but fail when the dest filename contains a German Umlaut (äöüÄÜÖ)
 * Upload will say "Successfully uploaded" but fail when the dest filename contains a comma
 * If upload succeeds, special characters in the wikitext will turn into gibberish


 * Update: I've managed to clean up the contents by encoding it as iso-8859-1:

No luck with the dest filename yet, though. I suppose the entire request should rather be utf-8 instead of these ugly hacks... --Magnus Manske (talk) 13:18, 8 August 2009 (UTC)


 * Update 2: Got it working now! Here's the code of the entire function:

I still think the iso-hack is ugly, though... --Magnus Manske (talk) 16:07, 8 August 2009 (UTC)
 * Yeah. I need to rewrite it for the upload API anyway, which will be with us on the next scap (Wikimania, perhaps?). Hopefully things will be saner then. MER-C 06:51, 9 August 2009 (UTC)

Bug in move?
Should be: ? --Nat3738 (talk) 03:16, 8 October 2009 (UTC)

Issue with the APIs returning blank lines before actual response
This may occur in several places, I found the problem in login and edit.

These are the changes I made to make it work

in login: becomes in edit the call to checkErrors causes an Exception if the first returned line is blank even though subsequent lines exist with the success message; you need to loop through the returned lines to check for success.

Glen.mccormick (talk) 13:56, 12 January 2010 (UTC)
 * at least on WMF sites. You're probably thinking of the XML pretty-print format. MER-C 05:35, 12 February 2010 (UTC)

Small corrections
Hello MER-C, I took the liberty to make 2 modifications on your code: But I did not modify the changelog. I hope you don't mind. In all cases, thanks a lot for your library and have a happy new year. Best regards, Liné1 (talk) 07:46, 2 January 2011 (UTC)
 * I corrected a bug when getCategories is called on non existing page or page without category
 * I corrected some javadoc
 * I corrected a bug when getImagesOnPage is called on non existing page or page without images
 * Thanks for the bug fixes. MER-C 09:33, 14 February 2011 (UTC)

Android compatible
I'm using your code for some android apps i'm writing ATM. I had to change some things as android java is missing some functions native java has i.e. isEmpty on Strings had to be replaced with equals("").

So i don't have to maintain the whole thing on my own ... is there any chance i could maintain android compatibility in your repo? My mail is at Freakolowsky. 10x. —Preceding undated comment added 15:13, 23 May 2011 (UTC).
 * Stop supporting stale versions of Android, then. MER-C 03:38, 10 September 2012 (UTC)

checkRights bug
Hi, im developing Commons:VicuñaUploader and I found bug related with cookies. If someone will log in not using uppercase in first letter (eg. "myaccount"), method  will return "myaccount", but cookies contatins "Myaccount" received from server. As a result CredentialExpiredException will be returned, but it should't. The same situation with spaces and underscores: server will return plus instead.

Fix below: protected boolean checkRights(int level, boolean move) throws IOException, CredentialException {       // check if we are logged out String s = user.getUsername; s = s.substring(0,1).toUpperCase + s.substring(1); //first to upper s = s.replace(" ", "+").replace("_", "+");          //spc to plus

if (!cookies.containsValue(s)) {           logger.log(Level.SEVERE, "Cookies have expired"); logout; throw new CredentialExpiredException("Cookies have expired."); } //(...) Cheers, Yarl ✉ 14:00, 8 September 2012 (UTC)
 * Noted. MER-C 03:35, 10 September 2012 (UTC)
 * OK, and is there an easy way to check upload progress? Yarl ✉ 12:59, 10 September 2012 (UTC)
 * The MW API is blocking serverside, so you will need to edit upload to update whatever progress bar you have. It is not possible to monitor single chunk uploads. MER-C 08:01, 17 September 2012 (UTC)
 * Might be fixed in r89 (not tested). MER-C 08:27, 17 September 2012 (UTC)