enkore / i3pystatus

A complete replacement for i3status
https://i3pystatus.readthedocs.io/
MIT License
445 stars 189 forks source link

mpd module emits error when icy-title's charset is not UTF-8. #744

Closed crocket closed 5 years ago

crocket commented 5 years ago

For many asian radio streams, icy-title's character encoding is not UTF-8.

The error is

2019-05-13 18:22:03,971 [ERROR   ][i3pystatus.mpd.MPD 100] Exception in Thread-4 at Mon May 13 18:22:03 2019, module MPD
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/i3pystatus/core/threading.py", line 92, in __call__
    self.workload()
  File "/usr/lib64/python3.6/site-packages/i3pystatus/core/modules.py", line 297, in __call__
    self.run()
  File "/usr/lib64/python3.6/site-packages/i3pystatus/mpd.py", line 155, in run
    "title": currentsong.get("Title", ""),
AttributeError: 'NoneType' object has no attribute 'get'

It's better to display broken characters than to emit errors.

enkore commented 5 years ago

80a0583 should at least prevent the exception, but will result in no current song information. I'm unsure how a proper fix would look like; MPD says the protocol is UTF-8, but seems to serve up non-UTF-8 at times?

2dd665d changes the decoding error handler to "replace", which should give you the familiar � for non-UTF-8 data. I suspect a proper fix (to get it to show the actual text) needs to be on mpd's side; it's probably too late when it reaches i3pystatus, we don't know the encoding of those fields.

crocket commented 5 years ago

There is no way to specify character encoding for icy-title in an m3u playlist in mpd.

https://github.com/MusicPlayerDaemon/MPD/issues/422

crocket commented 5 years ago

I installed the latest git commit, and the issue seems to have been fixed. I see broken characters instead of error. I let you decide whether the issue is fixed.

crocket commented 5 years ago

Closing it because it is considered fixed.