Beispiel #1
0
    def send_epg(self):
        """ Report EPG data """
        results = dict()

        # Fetch EPG data
        for date in ['yesterday', 'today', 'tomorrow']:

            channels = self._vtm_go_epg.get_epgs(date)
            for channel in channels:
                # Lookup channel data in our own CHANNELS dict
                channel_data = next((c for c in CHANNELS.values()
                                     if c.get('epg') == channel.key), None)
                if not channel_data:
                    _LOGGER.warning(
                        'Skipping EPG for %s since we don\'t know this channel',
                        channel.key)
                    continue

                key = channel_data.get('iptv_id')

                # Create channel in dict if it doesn't exists
                if key not in results.keys():
                    results[key] = []

                results[key].extend([
                    dict(
                        start=broadcast.time.isoformat(),
                        stop=(
                            broadcast.time +
                            timedelta(seconds=broadcast.duration)).isoformat(),
                        title=broadcast.title,
                        description=broadcast.description,
                        # subtitle=None,  # Not available in the API
                        # season=None,  # Not available in the API
                        # epsiode=None,  # Not available in the API
                        genre=broadcast.genre,
                        image=broadcast.thumb,
                        stream=kodiutils.url_for(
                            'play',
                            category=broadcast.playable_type,
                            item=broadcast.playable_uuid)
                        if broadcast.playable_uuid else None)
                    for broadcast in channel.broadcasts
                ])

        return dict(version=1, epg=results)
    def send_epg(self):
        """ Report EPG data """
        results = dict()

        # Fetch EPG data
        for date in ['yesterday', 'today', 'tomorrow']:

            channels = self._vtm_go_epg.get_epgs(date)
            for channel in channels:
                # Lookup channel data in our own CHANNELS dict
                channel_data = next((c for c in CHANNELS.values()
                                     if c.get('epg') == channel.key), None)
                if not channel_data:
                    _LOGGER.warning(
                        'Skipping EPG for %s since we don\'t know this channel',
                        channel.key)
                    continue

                key = channel_data.get('iptv_id')

                # Create channel in dict if it doesn't exists
                if key not in results.keys():
                    results[key] = []

                results[key].extend([
                    dict(
                        start=broadcast.time.isoformat(),
                        stop=(
                            broadcast.time +
                            timedelta(seconds=broadcast.duration)).isoformat(),
                        title=broadcast.title,
                        description=broadcast.description,
                        image=broadcast.image)
                    for broadcast in channel.broadcasts
                ])

        return dict(version=1, epg=results)