adibaewa / pylast

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

update_now_playing() and scrobble() does not accept integers where natural #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
update_now_playing() and scrobble() does not accept integers for arguments 
where such would be natural, e.g. last start time, duration, and track number. 
I have to convert them to strings myself to make it work.

Instead of exceptions due to concatenation of strings and integers I would like 
it to just work.

I'm running Pylast 0.5.5 and Python 2.6.6.

Original issue reported on code.google.com by stein.ma...@jodal.no on 15 Jan 2011 at 11:11

GoogleCodeExporter commented 9 years ago

Original comment by amr.hassan on 15 Jan 2011 at 11:13

GoogleCodeExporter commented 9 years ago
Fixed in r245.

Original comment by amr.hassan on 21 Jan 2011 at 10:38

GoogleCodeExporter commented 9 years ago
I tried removing str() where I had wrapped ints, as you can see at 
https://github.com/mopidy/mopidy/commit/62111c277cdd38854609527d1c1abdb4b8b96e45
. I then got the following error:

WARNING  Error submitting playing track to Last.fm: Malformed response from 
Last.fm. Underlying error:
ERROR    coercing to Unicode: need string or buffer, int found
Traceback (most recent call last):
  File "/home/jodal/dev/mopidy/mopidy/utils/process.py", line 66, in run
    self.run_inside_try()
  File "/home/jodal/dev/mopidy/mopidy/frontends/lastfm.py", line 68, in run_inside_try
    self.process_message(message)
  File "/home/jodal/dev/mopidy/mopidy/frontends/lastfm.py", line 89, in process_message
    self.stopped_playing(message['track'], message['stop_position'])
  File "/home/jodal/dev/mopidy/mopidy/frontends/lastfm.py", line 132, in stopped_playing
    mbid=(track.musicbrainz_id or ''))
  File "/usr/lib/pymodules/python2.6/pylast.py", line 480, in scrobble
    "track_number": track_number, "duration": duration, "stream_id": stream_id, "context": context, "mbid": mbid},))
  File "/usr/lib/pymodules/python2.6/pylast.py", line 514, in scrobble_many
    _Request(self, "track.scrobble", params).execute()
  File "/usr/lib/pymodules/python2.6/pylast.py", line 710, in __init__
    self.sign_it()
  File "/usr/lib/pymodules/python2.6/pylast.py", line 716, in sign_it
    self.params['api_sig'] = self._get_signature()
  File "/usr/lib/pymodules/python2.6/pylast.py", line 729, in _get_signature
    string += self.params[name]
TypeError: coercing to Unicode: need string or buffer, int found
INFO     Exiting (Unknown error)

Thus, it seems you miss a _unicode() or str() somewhere.

Original comment by stein.ma...@jodal.no on 21 Jan 2011 at 11:18

GoogleCodeExporter commented 9 years ago

Original comment by amr.hassan on 22 Jan 2011 at 12:07

GoogleCodeExporter commented 9 years ago
Hopefully, fixed in r247.

Original comment by amr.hassan on 22 Jan 2011 at 1:15