photo / import

Import tool companion for all of the export tools
http://theopenphotoproject.org
Apache License 2.0
16 stars 11 forks source link

Add support for Unicode encoded strings #11

Closed dcancel closed 12 years ago

dcancel commented 12 years ago

Hi,

I kept running into errors with unicode encoded strings in my Flickr photo titles and descriptions. I added some functions to deal with these strings.

Example

Sample string:

{"description": "Landing Page Examples", "license": "CC BY-NC-SA", "title": "Web Based Project Management Software for Ad Agencies and Creative Firms | MAC Friendly | Workamajig\u00ae", "dateUploaded": 1256573124, "photo": "http://farm3.staticflickr.com/2747/4047109978_ff3db1b4d9_o.png", "tags": "landingpages,performable", "dateTaken": 1256573124, "permission": false, "id": "4047109978"}

Error:

Found a total of 982 files to process
Processing 1 of 982 20091026T120524-4047109978.json ... 
Traceback (most recent call last):
  File "import.py", line 110, in <module>
    import_into_openphoto(client)
  File "import.py", line 66, in import_into_openphoto
    resp = client.post('/photo/upload.json', params)
  File "/Library/Python/2.7/site-packages/openphoto-0.1-py2.7.egg/openphoto/__init__.py", line 41, in post
    body = urllib.urlencode(params)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 1294, in urlencode
    v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xae' in position 100: ordinal not in range(128)
walkah commented 12 years ago

I think this should actually be fixed by https://github.com/openphoto/openphoto-python/commit/ccc6e6ba1c42c7c38c5403bb855d7b982631e34f - can you try updating openphoto-python and see if you still get the errors?

dcancel commented 12 years ago

Sounds good, thanks.