muh6mm3d / pylast

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

UnicodeDecodeError on scrobble response from Last.fm #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
During a call to scrobble() Pylast failes to process the response from Last.fm 
and crashes with a UnicodeDecodeError. I'm running Pylast 0.5.5 and Python 
2.6.6.

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 69, in run_insi
de_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 131, 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 801, in execute
    response = self._download_response()
  File "/usr/lib/pymodules/python2.6/pylast.py", line 791, in _download_response
    response_text = _unicode(response.read())
  File "/usr/lib/pymodules/python2.6/pylast.py", line 3401, in _unicode
    return unicode(text, "utf-8")
UnicodeDecodeError: 'utf8' codec can't decode byte 0x8b in position 1: invalid 
start byte

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

GoogleCodeExporter commented 9 years ago
Please try it with the 0.5.6 version. If the problem still persists, attach
a python script that produces this error.

-- Amr

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

GoogleCodeExporter commented 9 years ago
Seriously, the diff between 0.5.5 and 0.5.6 is one unrelated line of code...

Original comment by stein.ma...@jodal.no on 15 Jan 2011 at 11:25

GoogleCodeExporter commented 9 years ago
Please attach a Python script with parameters to _Network.scrobble that
reproduces this problem.

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

GoogleCodeExporter commented 9 years ago
It's hard to reproduce since it may be dependent on both finding the right 
track and the response from Last.fm. Though, looking at the byte found and the 
position I think this may be due to gzip compression of the response:

- 
http://stackoverflow.com/questions/3804572/encoding-problem-downloading-html-usi
ng-mechanize-and-python-2-6
- 
http://www.velocityreviews.com/forums/t724029-unicodedecodeerror-having-fetch-we
b-page.html

If the web service is well behaved, it may be enough to add a header to the 
request specifying that you're not interested in gzipped responses.

Original comment by stein.ma...@jodal.no on 15 Jan 2011 at 12:44

GoogleCodeExporter commented 9 years ago
It doesn't make sense to assume this is a compression problem since it works 
fine without decompressing any responses. It wouldn't be sending compressed 
responses randomly. Your problem may have been caused by a network error. You 
should start logging your scrobbles and see if any reproduces the issue and 
report back when that happens.

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

GoogleCodeExporter commented 9 years ago
This bug should also be fixed by r242.

Original comment by stein.ma...@jodal.no on 21 Jan 2011 at 10:04

GoogleCodeExporter commented 9 years ago

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