cinzas / homeassistant-enigma-player

This is a custom component for the media_player and notify platforms of Home Assistant. Integrates with enigma2 images running OpenWebIf
58 stars 23 forks source link

Update enigma.py #1

Closed adrianmihalko closed 5 years ago

adrianmihalko commented 6 years ago

Fix crash for playing local movies.

/web/subservices

<e2servicelist>
<e2service>
<e2servicereference>
1:0:0:0:0:0:0:0:0:0:/media/net/UBUNTU/movie/20181023 2055 - Slager TV - Drága családom - Az Emílio Família.ts
</e2servicereference>
<e2servicename>Drága családom - Az Emílio Família</e2servicename>
</e2service>
</e2servicelist>

While playing movies, service reference is 1:0:0:0:0:0:0:0:0:0: and no EPG available.

Without this fix plugin crashes:

2018-10-23 22:10:32 ERROR (MainThread) [homeassistant.components.media_player] enigma: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 251, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_job(self.update)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/media_player/enigma.py", line 193, in update
    xml = self.request_call('/web/epgservicenow?sRef=' + reference)
  File "/config/custom_components/media_player/enigma.py", line 152, in request_call
    return self._opener.open(uri, timeout=self._timeout).read().decode('UTF8')
  File "/usr/local/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/local/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/local/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/local/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.6/http/client.py", line 1250, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/local/lib/python3.6/http/client.py", line 1117, in putrequest
    self._output(request.encode('ascii'))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe1' in position 102: ordinal not in range(128)
adrianmihalko commented 6 years ago

I added multiple bouquet support too.

cinzas commented 5 years ago

Sorry, already implemented