Bugs item #3536400, was opened at 2012-06-19 12:52 Message generated for change (Comment added) made by betacommand You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3536400...
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: betacommand (betacommand) Assigned to: xqt (xqt) Summary: Invalid Title in flickrripper
Initial Comment: Betacommand multichill: I know you wrote flickrripper.py and Im trying to fix an issue with it, and thought it might be easier for you to fix Betacommand lines 157-161 where it grabs the description and uses it for the file name Betacommand when you start working with non-latin descriptions it doesnt handle multi-byte characters well, it ended up with a title over 320 bytes Betacommand the max mediawiki lets you have is 255 multichill Lol Betacommand multichill: really rather a pain multichill So the check shoul probably encode it and than see how long it is? Betacommand correct multichill Or just lower the limit a bit? Betacommand thai letters for example are 3 bytes Betacommand notes it was discovered with flickrripper.py -autonomous -user_id:40561337@N07 -addcategory:"Files from Abhisit Vejjajiva Flickr stream" multichill Betacommand: Could you file a bug for this? Betacommand multichill: you would need to cut it down to 85 to be safe
----------------------------------------------------------------------
Comment By: betacommand (betacommand)
Date: 2012-06-20 20:55
Message: those are the thai parts of the page title that are being converted when the exception is being thrown
----------------------------------------------------------------------
Comment By: xqt (xqt) Date: 2012-06-20 20:53
Message: Where are the html entities from? Are they part of the flickr page?
----------------------------------------------------------------------
Comment By: betacommand (betacommand) Date: 2012-06-20 16:45
Message: Issue still not fixed, actually its worse C:\Dev\SVN\pywikipedia>flickrripper.py -autonomous -user_id:40561337@N07 -addcat egory:"Files from Abhisit Vejjajiva Flickr stream" 5703017392 Traceback (most recent call last): File "C:\Dev\SVN\pywikipedia\flickrripper.py", line 609, in <module> main() File "C:\Dev\SVN\pywikipedia\flickrripper.py", line 599, in main removeCategories, autonomous) File "C:\Dev\SVN\pywikipedia\flickrripper.py", line 257, in processPhoto filename = getFilename(photoInfo) File "C:\Dev\SVN\pywikipedia\flickrripper.py", line 172, in getFilename % (title, project, username)).exists(): File "C:\Dev\SVN\pywikipedia\wikipedia.py", line 1284, in exists self.get() File "C:\Dev\SVN\pywikipedia\wikipedia.py", line 705, in get expandtemplates = expandtemplates) File "C:\Dev\SVN\pywikipedia\wikipedia.py", line 787, in _getEditPage raise BadTitle('BadTitle: %s' % self) pywikibot.exceptions.BadTitle: BadTitle: [[commons:File:นาย 585;รัฐมนตรี แลū
2;คณะเดินทางอ&
#3629;กจากกรุงจา# 85;าร์ตา สาธารณ
;รัฐอินโดนีเ&#
3595;ียกลับยังปũ 9;ะเทศไทย วันอ าทิตย์ที่ 8 พฤ ษภาคม พ.ศ.2554 (Photographer attached to the Prime Minister of the Kingdom of Thailand (H.E.Mr.Abhisit Vejjajiva) , Pe erapat Wimolrungkarat - พีรพัฒน์
วิมลรังครัต&# 3609;์) @is50mm - Flickr - Abhisit Vejjajiva.jpg]]
----------------------------------------------------------------------
Comment By: xqt (xqt) Date: 2012-06-20 07:17
Message: fix committed in r10387, please check
----------------------------------------------------------------------
Comment By: xqt (xqt) Date: 2012-06-20 00:08
Message: an idea for getFilename (could anybody test it whether it works)
if not title: #find the max length for a mw title maxBytes = 240 - len(project.encode('utf-8')) \ - len(username.encode('utf-8')) description = photoInfo.find('photo').find('description').text if description: descBytes = len(description.encode('utf-8')) if descBytes > maxBytes: # maybe we cut more than needed, anyway we do it items = max(0, len(description) - maxBytes + descBytes) description = description[:items] title = cleanUpTitle(description) else: title = u'' # Should probably have the id of the photo as last resort.
----------------------------------------------------------------------
Comment By: xqt (xqt) Date: 2012-06-19 23:03
Message: I guess the title is cutted by mw and not the slice operator since it works correct for unicode strings. len() also gives the number of characters not the number bytes. Do we have any size(object) method?
----------------------------------------------------------------------
You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=603138&aid=3536400...
pywikipedia-bugs@lists.wikimedia.org