ASCII encoding and wacky artist names
Opened this issue · 3 comments
I've got a very simple script that prints the currently playing artist to stdout. It's failing when trying to return "Janelle Monáe" (failing on the á, I assume) with the error:
Traceback (most recent call last):
File "scripts/now_playing.py", line 29, in <module>
artist = sq.get_track_artist()
File "build/bdist.macosx-10.8-intel/egg/pylms/player.py", line 266, in get_track_artist
UnicodeEncodeError: 'ascii' codec can't encode characters in position 11-12: ordinal not in range(128)
Forgive me if this is a basic question not having to do with your script (I'm not a python developer), but I do seem to be able to handle unicode in the script (print u"\u03A9" outputs Ω correctly, for example).
Thanks!
Hi mgeraci. Thanks for reporting this. I'm not sure anyone will have the time to look at it soon, but feel free to submit a fix if you manage to create one yourself :)
Absolutely! I'm happy to give it a shot, but I'm not sure how successful I'll be. Any pointers on places in the code to look?
I got it working (well, not crashing and putting in something vaguely like a replacement) by putting adding this unicode transformation line to server.py at line 100 in the request function,
result = result.strip()
result = unicodedata.normalize('NFD', result).encode('ascii','ignore')
return result