'Retrieve the latest data from the LG TV.'

@util.Throttle(MIN_TIME_BETWEEN_SCANS, MIN_TIME_BETWEEN_FORCED_SCANS)
def update(self):

    from pylgnetcast import LgNetCastError
    try:
        with self._client as client:
            self._state = STATE_PLAYING
            volume_info = client.query_data('volume_info')
            if volume_info:
                volume_info = volume_info[0]
                self._volume = float(volume_info.find('level').text)
                self._muted = (volume_info.find('mute').text == 'true')
            channel_info = client.query_data('cur_channel')
            if channel_info:
                channel_info = channel_info[0]
                self._channel_name = channel_info.find('chname').text
                self._program_name = channel_info.find('progName').text
            channel_list = client.query_data('channel_list')
            if channel_list:
                channel_names = []
                for channel in channel_list:
                    channel_name = channel.find('chname')
                    if (channel_name is not None):
                        channel_names.append(str(channel_name.text))
                self._sources = dict(zip(channel_names, channel_list))
                source_tuples = [(k, self._sources[k].find('major').text) for k in self._sources]
                sorted_sources = sorted(source_tuples, key=(lambda channel: int(channel[1])))
                self._source_names = [n for (n, k) in sorted_sources]
    except (LgNetCastError, RequestException):
        self._state = STATE_OFF
