LaurentCR / pylast

Automatically exported from code.google.com/p/pylast
Apache License 2.0
0 stars 0 forks source link

Authentication and MD5 with non-ASCII characters #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Please type example code that produces the issue:

user = User('Zazhigalo4ka', API_KEY, API_SECRET, SESSION_KEY)
p = user.getPlaylistIDs()
pid = p[0]
playlist = Playlist('lastfm://playlist/%s' % pid, API_KEY, API_SECRET, 
SESSION_KEY)
tracks = playlist.fetch()
t1 = tracks[1]
t1.getTitle()
t1.getTags()

What is the expected output? What do you see instead?

I expect the title (which is printed) and the tags (which are not printed). The 
following error is 
reported:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
pylast.py", line 514, in getTags
    doc = Request(self, self.ws_prefix + '.getTags', self.api_key, params, True, self.secret).execute
()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
pylast.py", line 285, in execute
    self.params['api_sig'] = self._getSignature()
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
pylast.py", line 275, in _getSignature
    hash.update(string)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 52-54: 
ordinal not in range
(128)

What version of pyLast is this?

pyLast-0.2b13

Please provide any additional information below.

This happens both with Python 2.5 and Python 2.6, and I guess the problem is 
related to the 
creation of the MD5 hash with a track that contains non-ASCII characters. The 
last.fm page
http://www.last.fm/api/authspec reminds to "Ensure your parameters are utf8 
encoded.", so the 
problem might be there.

(Thanks again for this package, by the way!!)

Original issue reported on code.google.com by claud...@gmail.com on 19 Oct 2008 at 4:27

GoogleCodeExporter commented 9 years ago
Fixed in 0.2.14, available in svn.
Check out the new UserPlaylist class as well.

Thank you for taking the time to report this.

Original comment by amr.hassan on 19 Oct 2008 at 10:51