faisalraja / flickrsmartsync

Sync your photos to flickr
121 stars 48 forks source link

UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128) #17

Closed tacoe closed 10 years ago

tacoe commented 10 years ago

Upon any sync I try.

INFO:flickrsmartsync:Getting photosets page 1 Traceback (most recent call last): File "/usr/local/bin/flickrsmartsync", line 9, in load_entry_point('flickrsmartsync==0.1.14.2', 'console_scripts', 'flickrsmartsync')() File "/usr/local/lib/python2.7/dist-packages/flickrsmartsync/init.py", line 318, in main start_sync(args.sync_path.rstrip(os.sep) + os.sep, args) File "/usr/local/lib/python2.7/dist-packages/flickrsmartsync/init.py", line 124, in start_sync desc = html_parser.unescape(set['description']['_content']).decode('utf-8') File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 1: ordinal not in range(128)

(trying on https://www.flickr.com/photos/tacoekkel/ )

JuXReal commented 10 years ago

Same for me. Some Ideas how to fix ?

pi@raspberrypi1 ~/btsync/fotos $ flickrsmartsync WARNING:flickrsmartsync:To avoid disorganization on flickr sets root photos are not synced, skipped these photos: ['Geburt Leslie.mp4', 'IMG_0700.MOV', 'IMG_0729.MOV', 'img005.jpg', 'IMG_0722.MOV', 'IMG_0703.MOV'] WARNING:flickrsmartsync:Try to sync at top most level of your photos directory INFO:flickrsmartsync:Getting photosets page 1 Traceback (most recent call last): File "/usr/local/bin/flickrsmartsync", line 9, in load_entry_point('flickrsmartsync==0.1.14.2', 'console_scripts', 'flickrsmartsync')() File "/usr/local/lib/python2.7/dist-packages/flickrsmartsync/init.py", line 318, in main start_sync(args.sync_path.rstrip(os.sep) + os.sep, args) File "/usr/local/lib/python2.7/dist-packages/flickrsmartsync/init.py", line 124, in start_sync desc = html_parser.unescape(set['description']['_content']).decode('utf-8') File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 14: ordinal not in range(128)

faisalraja commented 10 years ago

hmm I haven't really played much with encodings. I'll read up on it more. You could try removing .decode('utf-8') on line 124 and 169 or maybe put the known encoding of the system.

JuXReal commented 10 years ago

Mh, If i Chance the Python Lib - i am afraid that I get trouble with other scripts. Or have I understand that point wrong?

JuXReal commented 10 years ago

Hi - it seems this is a Problem with Python. The fix can be realy easy ( sorry - just a German Link ) - http://gelb.bcom.at/trac/misc/wiki/TutorialsPython/PythonUmlauteUnicodeEncodings

I Hope Googletranslate or somerhing can give you a hand

JuXReal commented 10 years ago

Sorry - i cant edit my own post with this browser .-/

coding: utf-8

insert in the 1/2 Line of Code ( Python ) - i cant try at the moment. But i will at weekend.

tititake commented 10 years ago

Hi

I'm a Chinese user, and I have the same problem. My environment is Gentoo Linux x64, locale en_US.UTF-8, python 2.7 .

INFO:flickrsmartsync:Getting photosets page 1 Traceback (most recent call last): File "/usr/bin/flickrsmartsync", line 9, in load_entry_point('flickrsmartsync==0.1.14.2', 'console_scripts', 'flickrsmartsync')() File "/usr/lib64/python2.7/site-packages/flickrsmartsync/init.py", line 321, in main start_sync(args.sync_path.rstrip(os.sep) + os.sep, args) File "/usr/lib64/python2.7/site-packages/flickrsmartsync/init.py", line 125, in start_sync desc = html_parser.unescape(set['description']['_content']).decode('utf-8') File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeEncodeError: 'ascii' codec can't encode characters in position 9-10: ordinal not in range(128)

I have to add 3 lines to set python's default encoding to utf-8, default is ascii.

file: /usr/lib64/python2.7/site-packages/flickrsmartsync/init.py

at the top of the file

import sys

after def main():

reload(sys) sys.setdefaultencoding('utf-8')

I'm not a python dev, I found it here(Chinese page). http://wangye.org/blog/archives/629/

Thanks for the useful tool.

JuXReal commented 10 years ago

I am sorry. I cant get it work.

I hope, that faisalraja can fix it soon. This is a realy great script. But it doesent work for me.

faisalraja commented 10 years ago

Added a fix, see if it works, version 1.14.3

JuXReal commented 10 years ago

Hell yeaha! It works! - thank you so much. pls let me know, how i cant give a Tip(?) for you and your Projekt!

tititake commented 10 years ago

Great! Fixed for me too.

faisalraja commented 10 years ago

Cool, @JuXReal these are all tools I use myself too so no need. Thanks!