コード例 #1
0
    def send_channels(self):
        """ Report channel data """
        # Fetch EPG from API
        channels = self._vtm_go.get_live_channels()

        results = []
        for channel in channels:
            channel_data = CHANNELS.get(channel.key)

            if not channel_data:
                _LOGGER.warning(
                    'Skipping %s since we don\'t know this channel',
                    channel.key)
                continue

            results.append(
                dict(
                    name=channel_data.get('label')
                    if channel_data else channel.name,
                    id=channel_data.get('iptv_id'),
                    preset=channel_data.get('iptv_preset'),
                    logo=
                    'special://home/addons/{addon}/resources/logos/{logo}.png'.
                    format(addon=kodiutils.addon_id(), logo=channel.key)
                    if channel_data else channel.logo,
                    stream=kodiutils.url_for('play',
                                             category='channels',
                                             item=channel.channel_id),
                    vod=kodiutils.url_for('play_epg_datetime',
                                          channel=channel.key,
                                          timestamp='{date}'),
                ))

        return dict(version=1, streams=results)
コード例 #2
0
    def show_mainmenu():
        """ Show the main menu """
        listing = [
            TitleItem(
                title=kodiutils.localize(30001),  # A-Z
                path=kodiutils.url_for('show_catalog'),
                art_dict=dict(
                    icon='DefaultMovieTitle.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30002), )),
            TitleItem(
                title=kodiutils.localize(30007),  # TV Channels
                path=kodiutils.url_for('show_channels'),
                art_dict=dict(
                    icon='DefaultAddonPVRClient.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30008), )),
            TitleItem(
                title=kodiutils.localize(30009),  # Search
                path=kodiutils.url_for('show_search'),
                art_dict=dict(
                    icon='DefaultAddonsSearch.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30010), ))
        ]

        kodiutils.show_listing(listing, sort=['unsorted'])
コード例 #3
0
    def generate_titleitem(cls, item):
        """ Generate a TitleItem.
        :param Union[Channel] item:         The item to convert to a TitleItem.

        :rtype: TitleItem
        """
        #
        # Program
        #
        if isinstance(item, Program):
            return TitleItem(
                title=item.title,
                path=kodiutils.url_for('play_asset', asset_id=item.uid),
                art_dict={
                    'cover': item.cover,
                    'icon': item.preview,
                    'thumb': item.preview,
                    'fanart': item.preview,
                },
                info_dict={
                    'tvshowtitle': item.title,
                    'plot': item.description,
                    'season': item.season,
                    'episode': item.episode,
                    'mediatype': 'episode',
                },
                is_playable=True,
            )

        #
        # Channel
        #
        if isinstance(item, Channel):
            return TitleItem(
                title=item.title,
                path=kodiutils.url_for('play_asset', asset_id=item.uid) +
                '?.pvr',
                art_dict={
                    'cover': item.icon,
                    'icon': item.icon,
                    'thumb': item.icon,
                    # 'fanart': item.preview,  # Preview doesn't seem to work on most channels
                },
                info_dict={
                    'title': item.title,
                    'plot': cls._format_channel_plot(item),
                    'playcount': 0,
                    'mediatype': 'video',
                },
                prop_dict={
                    'inputstream.adaptive.manifest_update_parameter': 'full',
                },
                is_playable=True,
            )

        raise Exception('Unknown type: %s' % item)
コード例 #4
0
    def show_channel_guide(self, channel_id):
        """ Shows the dates in the tv guide.

        :param str channel_id:          The channel for which we want to show an EPG.
        """
        listing = []
        for day in self._get_dates('%A %d %B %Y'):
            if day.get('highlight'):
                title = '[B]{title}[/B]'.format(title=day.get('title'))
            else:
                title = day.get('title')

            listing.append(
                TitleItem(
                    title=title,
                    path=kodiutils.url_for('show_channel_guide_detail',
                                           channel_id=channel_id,
                                           date=day.get('key')),
                    art_dict=dict(
                        icon='DefaultYear.png',
                        thumb='DefaultYear.png',
                    ),
                    info_dict=dict(
                        plot=None,
                        date=day.get('date'),
                    ),
                ))

        kodiutils.show_listing(listing, 30013, content='files')
コード例 #5
0
    def show_tvguide_channel(self, channel):
        """ Shows the dates in the tv guide
        :type channel: str
        """
        listing = []
        for day in self._vtm_go_epg.get_dates('%A %d %B %Y'):
            if day.get('highlight'):
                title = '[B]{title}[/B]'.format(title=day.get('title'))
            else:
                title = day.get('title')

            listing.append(kodiutils.TitleItem(
                title=title,
                path=kodiutils.url_for('show_tvguide_detail', channel=channel, date=day.get('key')),
                art_dict=dict(
                    icon='DefaultYear.png',
                    thumb='DefaultYear.png',
                ),
                info_dict=dict(
                    plot=None,
                    date=day.get('date'),
                ),
            ))

        kodiutils.show_listing(listing, 30013, content='files', sort=['date'])
コード例 #6
0
    def show_channels(self):
        """ Shows TV channels. """
        channels = self._channel_api.get_channels(
            filter_pin=kodiutils.get_setting_int(
                'interface_adult') == SETTINGS_ADULT_HIDE)

        # Load EPG details for the next 6 hours
        date_now = datetime.now(dateutil.tz.UTC)
        date_from = date_now.replace(minute=0, second=0, microsecond=0)
        date_to = (date_from + timedelta(hours=6))
        epg = self._epg_api.get_guide([channel.uid for channel in channels],
                                      date_from, date_to)
        for channel in channels:
            shows = [
                show for show in epg.get(channel.uid, {})
                if show.end > date_now
            ]
            try:
                channel.epg_now = shows[0]
            except (IndexError, KeyError):
                pass
            try:
                channel.epg_next = shows[1]
            except (IndexError, KeyError):
                pass

        listing = []
        for item in channels:
            title_item = Menu.generate_titleitem_channel(item)
            title_item.path = kodiutils.url_for('show_channel',
                                                channel_id=item.get_combi_id())
            title_item.is_playable = False
            listing.append(title_item)

        kodiutils.show_listing(listing, 30007)
コード例 #7
0
    def show_recommendations(self, storefront):
        """ Show the recommendations.

        :type storefront: str
        """
        results = self._api.get_storefront(storefront)
        show_unavailable = kodiutils.get_setting_bool(
            'interface_show_unavailable')

        listing = []
        for item in results:
            if isinstance(item, Category):
                listing.append(
                    TitleItem(
                        title=item.title,
                        path=kodiutils.url_for('show_recommendations_category',
                                               storefront=storefront,
                                               category=item.category_id),
                        info_dict=dict(plot='[B]{category}[/B]'.format(
                            category=item.title), ),
                    ))
            else:
                if show_unavailable or item.available:
                    listing.append(Menu.generate_titleitem(item))

        if storefront == STOREFRONT_SERIES:
            label = 30005  # Series
        elif storefront == STOREFRONT_MOVIES:
            label = 30003  # Movies
        else:
            label = 30015  # Recommendations

        kodiutils.show_listing(listing, label, content='files')
コード例 #8
0
    def show_channel(self, channel):
        """ Shows the dates in the tv guide
        :type channel: str
        """
        listing = []
        for day in self.get_dates('%A %d %B %Y'):
            if day.get('highlight'):
                title = '[B]{title}[/B]'.format(title=day.get('title'))
            else:
                title = day.get('title')

            listing.append(
                TitleItem(title=title,
                          path=kodiutils.url_for('show_channel_tvguide_detail',
                                                 channel=channel,
                                                 date=day.get('key')),
                          art_dict={
                              'icon': 'DefaultYear.png',
                              'thumb': 'DefaultYear.png',
                          },
                          info_dict={
                              'plot': None,
                              'date': day.get('date'),
                          }))

        kodiutils.show_listing(listing, 30013, content='files', sort=['date'])
コード例 #9
0
    def generate_titleitem_series(cls, item):
        """ Generate a TitleItem.

        :param resources.lib.solocoo.util.Program item: The Program to convert to a TitleItem.

        :returns:                       A generated TitleItem for a Series.
        :rtype: TitleItem
        """
        return TitleItem(
            title=item.title,
            path=kodiutils.url_for('show_channel_replay_series',
                                   series_id=item.series_id),
            art_dict={
                'cover': item.cover,
                'icon': item.preview,
                'thumb': item.preview,
                'fanart': item.preview,
            },
            info_dict={
                'mpaa': item.age,
                'tvshowtitle': item.title,
                'title': item.title,
                'plot': None,
            },
        )
コード例 #10
0
    def select_profile(self, key=None):
        """ Show your profiles.

        :type key: str
        """
        profiles = self._auth.get_profiles()

        # Show warning when you have no profiles
        if not profiles:
            # Your account has no profiles defined. Please login on www.streamz.be/streamz and create a profile.
            kodiutils.ok_dialog(message=kodiutils.localize(30703))
            kodiutils.end_of_directory()
            return

        # Select the first profile when you only have one
        if len(profiles) == 1:
            key = profiles[0].key

        # Save the selected profile
        if key:
            profile = [x for x in profiles if x.key == key][0]
            _LOGGER.debug('Setting profile to %s', profile)
            kodiutils.set_setting('profile',
                                  '%s:%s' % (profile.key, profile.product))
            kodiutils.set_setting('profile_name', profile.name)

            kodiutils.redirect(kodiutils.url_for('show_main_menu'))
            return

        # Show profile selection when you have multiple profiles
        listing = [
            TitleItem(
                title=self._get_profile_name(p),
                path=kodiutils.url_for('select_profile', key=p.key),
                art_dict=dict(icon='DefaultUser.png'),
                info_dict=dict(plot=p.name, ),
            ) for p in profiles
        ]

        kodiutils.show_listing(listing, sort=['unsorted'],
                               category=30057)  # Select Profile
コード例 #11
0
    def play_epg_datetime(self, channel, timestamp):
        """ Play a program based on the channel and the timestamp when it was aired
        :type channel: str
        :type timestamp: str
        """
        broadcast = self._vtm_go_epg.get_broadcast(channel, timestamp)
        if not broadcast:
            kodiutils.ok_dialog(heading=kodiutils.localize(30711), message=kodiutils.localize(30713))  # The requested video was not found in the guide.
            kodiutils.end_of_directory()
            return

        kodiutils.redirect(
            kodiutils.url_for('play', category=broadcast.playable_type, item=broadcast.playable_uuid))
コード例 #12
0
    def show_recommendations(self):
        """ Shows the recommendations """
        # "Meest bekeken" has a specific API endpoint, the other categories are scraped from the website.
        listing = [
            TitleItem(title='Meest bekeken',
                      path=kodiutils.url_for('show_recommendations_category',
                                             category='meest-bekeken'),
                      info_dict={
                          'title': 'Meest bekeken',
                      })
        ]

        recommendations = self._api.get_recommendation_categories()
        for category in recommendations:
            listing.append(
                TitleItem(title=category.title,
                          path=kodiutils.url_for(
                              'show_recommendations_category',
                              category=category.uuid),
                          info_dict={
                              'title': category.title,
                          }))

        kodiutils.show_listing(listing, 30005, content='tvshows')
コード例 #13
0
    def show_categories(self):
        """ Shows the categories """
        categories = self._api.get_categories()

        listing = []
        for category in categories:
            listing.append(
                TitleItem(title=category.title,
                          path=kodiutils.url_for('show_category',
                                                 category=category.uuid),
                          info_dict={
                              'title': category.title,
                          }))

        kodiutils.show_listing(listing, 30003, sort=['title'])
コード例 #14
0
    def show_catalog(self):
        """ Show the catalog. """
        categories = self._api.get_categories()

        listing = []
        for cat in categories:
            listing.append(TitleItem(
                title=cat.title,
                path=kodiutils.url_for('show_catalog_category', category=cat.category_id),
                info_dict=dict(
                    plot='[B]{category}[/B]'.format(category=cat.title),
                ),
            ))

        # Sort categories by default like in Streamz.
        kodiutils.show_listing(listing, 30003, content='files')
コード例 #15
0
    def show_mainmenu():
        """ Show the main menu """
        listing = [
            TitleItem(
                title=kodiutils.localize(30001),  # A-Z
                path=kodiutils.url_for('show_catalog'),
                art_dict=dict(
                    icon='DefaultMovieTitle.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30002), )),
            TitleItem(
                title=kodiutils.localize(30007),  # TV Channels
                path=kodiutils.url_for('show_channels'),
                art_dict=dict(
                    icon='DefaultAddonPVRClient.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30008), )),
            TitleItem(
                title=kodiutils.localize(30003),  # Catalog
                path=kodiutils.url_for('show_categories'),
                art_dict=dict(
                    icon='DefaultGenre.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30004), )),
            TitleItem(
                title=kodiutils.localize(30005),  # Recommendations
                path=kodiutils.url_for('show_recommendations'),
                art_dict=dict(
                    icon='DefaultFavourites.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30006), )),
            TitleItem(
                title=kodiutils.localize(30011),  # My List
                path=kodiutils.url_for('show_mylist'),
                art_dict=dict(
                    icon='DefaultPlaylist.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30012), )),
            TitleItem(
                title=kodiutils.localize(30009),  # Search
                path=kodiutils.url_for('show_search'),
                art_dict=dict(
                    icon='DefaultAddonsSearch.png',
                    fanart=kodiutils.get_addon_info('fanart'),
                ),
                info_dict=dict(plot=kodiutils.localize(30010), ))
        ]

        kodiutils.show_listing(listing, sort=['unsorted'])
コード例 #16
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)
コード例 #17
0
    def play_epg_datetime(self, channel, timestamp):
        """ Play a program based on the channel and the timestamp when it was aired
        :type channel: str
        :type timestamp: str
        """
        broadcast = self._epg.get_broadcast(channel, timestamp)
        if not broadcast:
            kodiutils.ok_dialog(
                heading=kodiutils.localize(30711),
                message=kodiutils.localize(
                    30713))  # The requested video was not found in the guide.
            kodiutils.end_of_directory()
            return

        kodiutils.container_update(
            kodiutils.url_for('play',
                              channel=channel,
                              uuid=broadcast.video_url))
コード例 #18
0
    def send_epg():  # pylint: disable=no-method-argument
        """Return JSON-EPG formatted information to IPTV Manager"""
        epg_api = EpgApi()

        try:  # Python 3
            from urllib.parse import quote
        except ImportError:  # Python 2
            from urllib import quote

        today = datetime.today()

        results = {}
        for key, channel in CHANNELS.items():
            iptv_id = channel.get('iptv_id')

            if channel.get('iptv_id'):
                results[iptv_id] = []

                for i in range(-3, 7):
                    date = today + timedelta(days=i)
                    epg = epg_api.get_epg(key, date.strftime('%Y-%m-%d'))

                    results[iptv_id].extend([
                        dict(start=program.start.isoformat(),
                             stop=(program.start + timedelta(
                                 seconds=program.duration)).isoformat(),
                             title=program.program_title,
                             subtitle=program.episode_title,
                             description=program.description,
                             episode='S%sE%s' %
                             (program.season, program.number)
                             if program.season and program.number else None,
                             genre=program.genre,
                             genre_id=program.genre_id,
                             image=program.thumb,
                             stream=kodiutils.url_for(
                                 'play_from_page',
                                 channel=key,
                                 page=quote(program.video_url, safe=''))
                             if program.video_url else None) for program in epg
                        if program.duration
                    ])

        return dict(version=1, epg=results)
コード例 #19
0
    def show_recommendations(self, storefront):
        """ Show the recommendations.

        :type storefront: str
        """
        recommendations = self._api.get_recommendations(storefront)

        listing = []
        for cat in recommendations:
            listing.append(TitleItem(
                title=cat.title,
                path=kodiutils.url_for('show_recommendations_category', storefront=storefront, category=cat.category_id),
                info_dict=dict(
                    plot='[B]{category}[/B]'.format(category=cat.title),
                ),
            ))

        # Sort categories by default like in Streamz.
        kodiutils.show_listing(listing, 30015, content='files')
コード例 #20
0
    def send_channels(self):
        """ Return JSON-STREAMS formatted information to IPTV Manager. """
        channel_api = ChannelApi(self._auth)

        streams = []

        channels = channel_api.get_channels(
            filter_pin=kodiutils.get_setting_int(
                'interface_adult') == SETTINGS_ADULT_HIDE)
        for channel in channels:
            streams.append(
                dict(
                    name=channel.title,
                    stream=kodiutils.url_for('play_asset',
                                             asset_id=channel.uid),
                    id=channel.station_id,
                    logo=channel.icon,
                    preset=channel.number,
                ))

        return dict(version=1, streams=streams)
コード例 #21
0
    def show_recommendations(self, storefront):
        """ Show the recommendations.

        :type storefront: str
        """
        try:
            results = self._vtm_go.get_storefront(storefront)
        except ApiUpdateRequired:
            kodiutils.ok_dialog(message=kodiutils.localize(
                30705))  # The VTM GO Service has been updated...
            return

        except Exception as ex:  # pylint: disable=broad-except
            _LOGGER.error("%s", ex)
            kodiutils.ok_dialog(message="%s" % ex)
            return

        listing = []
        for item in results:
            if isinstance(item, Category):
                listing.append(
                    kodiutils.TitleItem(
                        title=item.title,
                        path=kodiutils.url_for('show_recommendations_category',
                                               storefront=storefront,
                                               category=item.category_id),
                        info_dict=dict(plot='[B]{category}[/B]'.format(
                            category=item.title), ),
                    ))
            else:
                listing.append(Menu.generate_titleitem(item))

        if storefront == STOREFRONT_SERIES:
            label = 30005  # Series
        elif storefront == STOREFRONT_MOVIES:
            label = 30003  # Movies
        else:
            label = 30015  # Recommendations

        kodiutils.show_listing(listing, label, content='files')
コード例 #22
0
    def generate_titleitem_channel(cls, item):
        """ Generate a TitleItem for a Channel.

        :param resources.lib.solocoo.util.Channel item: The Channel to convert to a TitleItem.

        :returns:                       A generated TitleItem for a Channel.
        :rtype: TitleItem
        """
        if item.epg_now:
            title = item.title + '[COLOR gray] | {title} ({start} - {end})[/COLOR]'.format(
                title=item.epg_now.title,
                start=item.epg_now.start.strftime('%H:%M'),
                end=item.epg_now.end.strftime('%H:%M'))
        else:
            title = item.title

        return TitleItem(
            title=title,
            path=kodiutils.url_for('play_asset', asset_id=item.uid) + '?.pvr',
            art_dict={
                'cover': item.icon,
                'icon': item.icon,
                'thumb': item.icon,
                # 'fanart': item.preview,  # Preview doesn't seem to work on most channels
            },
            info_dict={
                'title': item.title,
                'plot': cls._format_channel_plot(item),
                'playcount': 0,
                'mediatype': 'video',
            },
            prop_dict={
                'inputstream.adaptive.manifest_update_parameter': 'full',
            },
            is_playable=True,
        )