def async_update(self): """Retrieve the latest data.""" import pyteleloisirs try: self._state = self.refresh_state() # Update current channel channel = self._client.channel if channel is not None: self._current_channel = channel program = yield from \ self._client.async_get_current_program() if program and self._current_program != program.get('name'): self._current_program = program.get('name') # Media progress info self._media_duration = \ pyteleloisirs.get_program_duration(program) rtime = pyteleloisirs.get_remaining_time(program) if rtime != self._media_remaining_time: self._media_remaining_time = rtime self._media_last_updated = dt_util.utcnow() # Set media image to current program if a thumbnail is # available. Otherwise we'll use the channel's image. img_size = 800 prg_img_url = yield from \ self._client.async_get_current_program_image(img_size) if prg_img_url: self._media_image_url = prg_img_url else: chan_img_url = \ self._client.get_current_channel_image(img_size) self._media_image_url = chan_img_url except requests.ConnectionError: self._state = None
def async_update(self): """Retrieve the latest data.""" import pyteleloisirs try: self._state = self.refresh_state() # Update channel list self.refresh_channel_list() # Update current channel channel = self._client.channel if channel is not None: self._current_channel = channel program = yield from \ self._client.async_get_current_program() if program and self._current_program != program.get('name'): self._current_program = program.get('name') # Media progress info self._media_duration = \ pyteleloisirs.get_program_duration(program) rtime = pyteleloisirs.get_remaining_time(program) if rtime != self._media_remaining_time: self._media_remaining_time = rtime self._media_last_updated = dt_util.utcnow() # Set media image to current program if a thumbnail is # available. Otherwise we'll use the channel's image. img_size = 800 prg_img_url = yield from \ self._client.async_get_current_program_image(img_size) if prg_img_url: self._media_image_url = prg_img_url else: chan_img_url = \ self._client.get_current_channel_image(img_size) self._media_image_url = chan_img_url except requests.ConnectionError: self._state = None