eonpatapon / mpDris2

MPRIS V2.1 support for mpd
GNU General Public License v3.0
210 stars 46 forks source link

crash when status.time is not an integer #84

Closed arcresu closed 7 years ago

arcresu commented 7 years ago

Whenever I start mpdris2, it crashes with:

Traceback (most recent call last):
  File "/usr/bin/mpDris2", line 1310, in <module>
    mpd_wrapper.run()
  File "/usr/bin/mpDris2", line 279, in run
    if self.my_connect():
  File "/usr/bin/mpDris2", line 354, in my_connect
    self.timer_callback()
  File "/usr/bin/mpDris2", line 442, in timer_callback
    self._update_properties(force=False)
  File "/usr/bin/mpDris2", line 672, in _update_properties
    new_position = int(new_status['time'].split(':')[0])
ValueError: invalid literal for int() with base 10: '149.433715'

It seems that mpd requires integer calues for times, but the particular server I'm using (beets bpd) has a bug (beetbox/beets#2394) where it is returning non-integers. The problem is with the server implementation, however every other mpd client software I've tried has been able to cope with the malformed response from this server.

Perhaps the handling of status fields could be a bit more robust? Changing int() to int(float()) would fix this particular issue, but it could be even more robust than that, and for other fields as well.

hashhar commented 7 years ago

Just to let people know. Upstream has fixed the issue so this doesn't need to be implemented.

arcresu commented 7 years ago

While the bug in beets may have been fixed, this issue is independent of that; I was only using it as an example.

My point was that some other mpd clients could handle the malformed input since they were a little more forgiving. The mpd API seems a bit underspecified: the fact that only integers should be provided here is not documented for example. Of course this is unlikely to be an issue if you only want to support mpd itself and not unofficial implementations.