patolin / pylast

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

IndexError on doc.getElementsByTagName('lfm')[0] #76

Open GoogleCodeExporter opened 9 years ago

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

Mopidy tried registering a "now playing" event using pylast, but pylast failed, 
probably because of a misformed response from Last.fm. From Mopidy's debug log:

DEBUG    2012-03-07 13:28:00,874 [25171:PykkaActorThread-955] 
mopidy.frontends.mpd
  Response to [::ffff:127.0.0.1]:51729 from urn:uuid:017562d5-4b12-4d6d-888c-70a97324ac39: 
    file: spotify:track:29c2Hhj9rT1B6dUM4MvPQ7
    Time: 341
    Artist: Netsky
    Title: Storm Clouds
    Album: Netsky
    Date: 2010-01-01
    Track: 7
    Pos: 6
    Id: 209
    OK
DEBUG    2012-03-07 13:28:00,875 [25171:PykkaActorThread-955] 
mopidy.frontends.mpd
  Request from [::ffff:127.0.0.1]:51729 to urn:uuid:017562d5-4b12-4d6d-888c-70a97324ac39: idle
DEBUG    2012-03-07 13:28:01,336 [25171:PykkaActorThread-7] 
mopidy.frontends.lastfm
  Now playing track: Netsky - Storm Clouds
ERROR    2012-03-07 13:28:01,419 [25171:PykkaActorThread-7] pykka
  Unhandled exception in LastfmFrontend (urn:uuid:b42051c2-388a-44d6-bca1-214690a21c9d):
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/pykka/actor.py", line 166, in _run
    response = self._handle_receive(message)
  File "/usr/lib/pymodules/python2.7/pykka/actor.py", line 237, in _handle_receive
    return callee(*message['args'], **message['kwargs'])
  File "/home/sjodal/dev/mopidy/mopidy/frontends/lastfm.py", line 73, in track_playback_started
    mbid=(track.musicbrainz_id or ''))
  File "/usr/lib/python2.7/dist-packages/pylast.py", line 465, in update_now_playing
    _Request(self, "track.updateNowPlaying", params).execute()
  File "/usr/lib/python2.7/dist-packages/pylast.py", line 828, in execute
    response = self._download_response()
  File "/usr/lib/python2.7/dist-packages/pylast.py", line 819, in _download_response
    self._check_response_for_errors(response_text)
  File "/usr/lib/python2.7/dist-packages/pylast.py", line 840, in _check_response_for_errors
    e = doc.getElementsByTagName('lfm')[0]
IndexError: list index out of range

It would be nice if pylast could handle errors like this without crashing.

I'm running pylast 0.5.11 on Python 2.7.2.

Original issue reported on code.google.com by stein.ma...@jodal.no on 7 Mar 2012 at 12:58

GoogleCodeExporter commented 9 years ago
Does this still happen? 

I couldn't reproduce it with my fork:
https://github.com/hugovk/pylast/issues/77

Original comment by hugovk@gmail.com on 17 Apr 2014 at 1:54