python-plexapi: data.strip() return 'Failure: 200 OK'

homeassistant control players return error:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/Users/chenyun/Projects/home-assistant/lib/python3.6/site-packages/homeassistant/helpers/service.py", line 277, in _handle_service_platform_call
    await getattr(entity, func)(**data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/Users/chenyun/Projects/home-assistant/lib/python3.6/site-packages/homeassistant/components/media_player/plex.py", line 716, in media_play
    self.device.play(self._active_media_plexapi_type)
  File "/Users/chenyun/Projects/home-assistant/lib/python3.6/site-packages/plexapi/client.py", line 308, in play
    self.sendCommand('playback/play', type=mtype)
  File "/Users/chenyun/Projects/home-assistant/lib/python3.6/site-packages/plexapi/client.py", line 196, in sendCommand
    return self.query(key, headers=headers)
  File "/Users/chenyun/Projects/home-assistant/lib/python3.6/site-packages/plexapi/client.py", line 168, in query
    return ElementTree.fromstring(data) if data.strip() else None
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/xml/etree/ElementTree.py", line 1314, in XML
    parser.feed(text)
  File "<string>", line None
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0

I tried to view the data of data.strip() and returned:

b'Failure: 200 OK'

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (1 by maintainers)

Most upvoted comments

Plex never fixes errors. They are far too busy developing half-assed features that nobody wants.

Empty responses should be handled properly by plexapi imo. They are pretty common.

If it’s malformed JSON, then we shouldn’t handle it. We made a conscious decision early on not to write specific code to handle all the various clients sending us different information. It would get unwieldy too quick.

So this response is essentially saying “Failure: Everything Good!!” Great API Plex. 😛 – Perhaps we just treat this specific string as an empty response Failure: 200 OK?