offmessage / pyscrobbler

Python bindings for the last.fm API

Home Page:http://github.com/offmessage/pyscrobbler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Song data can't be handed in as unicode

palfrey opened this issue · comments

I've got artist names/track names/album names that are already in unicode, and so can't be decoded by addtrack. There should be an option to set the encoding as "unicode" and so therefore only do the encode to utf-8 step, not the decode.

Hello

Can you be a bit more specific? Could you paste a traceback, point me at the line number and/or provide track details?

Cheers

Andy

The following is a part of a log from my program nih. player.py and jsonfuncs.py are my code, and audioscrobbler.py is a symlinked copy of the same named file checked out from pyscrobbler (there's a copy of the repo elsewhere in the source tree). "track" is the data that we're trying to submit via a copy of AudioScrobblerPost as generated according to the examples in the audioscrobbler.py comments, and audioscrobbler.enc has been set to "utf8"

[Wed Jan 11 11:16:45 2012] [error] track {'album': u'Ralf & Florian', 'length': 224, 'song_title': u'Heimatkl\xe4nge', 'date_played': '2012-01-11 11:16:45', 'mbid': '', 'artist_name': u'Kraftwerk'}
[Wed Jan 11 11:16:45 2012] [error] Traceback (most recent call last):
[Wed Jan 11 11:16:45 2012] [error] File "/usr/share/nih/simple_player/player.py", line 45, in message_handler
[Wed Jan 11 11:16:45 2012] [error] self.next_track()
[Wed Jan 11 11:16:45 2012] [error] File "/usr/share/nih/jukebox/jsonfuncs.py", line 200, in next_track
[Wed Jan 11 11:16:45 2012] [error] play_current()
[Wed Jan 11 11:16:45 2012] [error] File "/usr/share/nih/jukebox/jsonfuncs.py", line 240, in play_current
[Wed Jan 11 11:16:45 2012] [error] post(**track)
[Wed Jan 11 11:16:45 2012] [error] File "/usr/share/nih/jukebox/audioscrobbler.py", line 716, in posttrack
[Wed Jan 11 11:16:45 2012] [error] mbid=mbid)
[Wed Jan 11 11:16:45 2012] [error] File "/usr/share/nih/jukebox/audioscrobbler.py", line 747, in addtrack
[Wed Jan 11 11:16:45 2012] [error] 't[%s]': song_title.decode(enc).encode('utf8'),
[Wed Jan 11 11:16:45 2012] [error] File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
[Wed Jan 11 11:16:45 2012] [error] return codecs.utf_8_decode(input, errors, True)
[Wed Jan 11 11:16:45 2012] [error] UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 8: ordinal not in range(128)