コード例 #1
0
def show_livetv():
    kids = _get_kids_mode()
    try:
        _vtmGo = VtmGo(kids=kids)
        channels = _vtmGo.get_live()
    except Exception as ex:
        notification(message=str(ex))
        raise

    for channel in channels:
        listitem = ListItem(channel.name, offscreen=True)

        # Try to use the white icons for thumbnails (used for icons as well)
        if get_cond_visibility(
                'System.HasAddon(resource.images.studios.white)') == 1:
            thumb = 'resource://resource.images.studios.white/{studio}.png'.format(
                studio=channel.name)
        else:
            thumb = channel.logo

        # Try to use the coloured icons for fanart
        if get_cond_visibility(
                'System.HasAddon(resource.images.studios.coloured)') == 1:
            fanart = 'resource://resource.images.studios.coloured/{studio}.png'.format(
                studio=channel.name)
        elif get_cond_visibility(
                'System.HasAddon(resource.images.studios.white)') == 1:
            fanart = 'resource://resource.images.studios.white/{studio}.png'.format(
                studio=channel.name)
        else:
            fanart = channel.logo

        listitem.setInfo(
            'video', {
                'plot': _format_plot(channel),
                'playcount': 0,
                'studio': channel.name,
                'mediatype': channel.mediatype,
            })
        listitem.setArt({
            'icon': channel.logo,
            'fanart': fanart,
            'thumb': thumb,
        })
        listitem.setProperty('IsPlayable', 'true')

        xbmcplugin.addDirectoryItem(
            plugin.handle,
            plugin.url_for(play_livetv, channel=channel.id) + '?.pvr',
            listitem)

    # Sort live channels by default like in VTM GO.
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_UNSORTED)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.endOfDirectory(plugin.handle)
コード例 #2
0
ファイル: iptvsimple.py プロジェクト: Lunatixz/repo-scripts
    def restart(cls, force=False):
        """Restart IPTV Simple"""
        if not force and (kodiutils.get_cond_visibility('Pvr.IsPlayingTv') or kodiutils.get_cond_visibility('Pvr.IsPlayingRadio')):
            # Don't restart when we are Playing TV or Radio
            cls.restart_required = True
            _LOGGER.info('Postponing restart of Simple IPTV since it is currently in use.')
            return

        cls.restart_required = False

        cls._deactivate()
        time.sleep(1)
        cls._activate()
コード例 #3
0
def show_youtube():
    kids = _get_kids_mode()
    from resources.lib import YOUTUBE
    for entry in YOUTUBE:
        # Skip non-kids channels when we are in kids mode.
        if kids and entry.get('kids') is False:
            continue

        # Try to use the white icons for thumbnails (used for icons as well)
        if get_cond_visibility(
                'System.HasAddon(resource.images.studios.white)') == 1:
            thumb = 'resource://resource.images.studios.white/{studio}.png'.format(
                **entry)
        else:
            thumb = 'DefaultTags.png'

        # Try to use the coloured icons for fanart
        if get_cond_visibility(
                'System.HasAddon(resource.images.studios.coloured)') == 1:
            fanart = 'resource://resource.images.studios.coloured/{studio}.png'.format(
                **entry)
        elif get_cond_visibility(
                'System.HasAddon(resource.images.studios.white)') == 1:
            fanart = 'resource://resource.images.studios.white/{studio}.png'.format(
                **entry)
        else:
            fanart = 'DefaultTags.png'

        listitem = ListItem(entry.get('label'), offscreen=True)
        listitem.setInfo(
            'video', {
                'plot': 'Watch [B]%(label)s[/B] on YouTube' % entry,
                'studio': entry.get('studio'),
                'mediatype': 'video',
            })
        listitem.setArt({
            'icon': 'DefaultTags.png',
            'fanart': fanart,
            'thumb': thumb,
        })
        xbmcplugin.addDirectoryItem(plugin.handle, entry.get('path'), listitem,
                                    True)

    # Sort by default like in our dict.
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_UNSORTED)
    xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.endOfDirectory(plugin.handle)
コード例 #4
0
    def show_channel_menu(key):
        """ Shows a TV channel
        :type key: str
        """
        channel = CHANNELS[key]

        # Lookup the high resolution logo based on the channel name
        fanart = '{path}/resources/logos/{logo}'.format(path=kodiutils.addon_path(), logo=channel.get('background'))

        listing = [
            TitleItem(
                title=kodiutils.localize(30053, channel=channel.get('name')),  # TV Guide for {channel}
                path=kodiutils.url_for('show_tvguide_channel', channel=key),
                art_dict={
                    'icon': 'DefaultAddonTvInfo.png',
                    'fanart': fanart,
                },
                info_dict={
                    'plot': kodiutils.localize(30054, channel=channel.get('name')),  # Browse the TV Guide for {channel}
                }
            ),
            TitleItem(
                title=kodiutils.localize(30055, channel=channel.get('name')),  # Catalog for {channel}
                path=kodiutils.url_for('show_catalog_channel', channel=key),
                art_dict={
                    'icon': 'DefaultMovieTitle.png',
                    'fanart': fanart,
                },
                info_dict={
                    'plot': kodiutils.localize(30056, channel=channel.get('name')),  # Browse the Catalog for {channel}
                }
            )
        ]

        # Add YouTube channels
        if kodiutils.get_cond_visibility('System.HasAddon(plugin.video.youtube)') != 0:
            for youtube in channel.get('youtube', []):
                listing.append(
                    TitleItem(
                        title=kodiutils.localize(30206, label=youtube.get('label')),  # Watch {label} on YouTube
                        path=youtube.get('path'),
                        info_dict={
                            'plot': kodiutils.localize(30206, label=youtube.get('label')),  # Watch {label} on YouTube
                        }
                    )
                )

        kodiutils.show_listing(listing, 30007, sort=['unsorted'])
コード例 #5
0
    def show_channel_menu(self, key):
        """ Shows a TV channel
        :type key: str
        """
        # Fetch EPG from API
        channel = self._vtm_go.get_live_channel(key)
        channel_data = CHANNELS.get(channel.key)

        icon = channel.logo
        fanart = channel.background
        title = channel.name
        if channel_data:
            icon = '{path}/resources/logos/{logo}-white.png'.format(path=kodiutils.addon_path(), logo=channel.key)
            title = channel_data.get('label')

        title = kodiutils.localize(30052, channel=title)  # Watch live {channel}
        if channel.epg:
            label = title + '[COLOR gray] | {title} ({start} - {end})[/COLOR]'.format(
                title=channel.epg[0].title,
                start=channel.epg[0].start.strftime('%H:%M'),
                end=channel.epg[0].end.strftime('%H:%M'))
        else:
            label = title

        # The .pvr suffix triggers some code paths in Kodi to mark this as a live channel
        listing = [kodiutils.TitleItem(
            title=label,
            path=kodiutils.url_for('play', category='channels', item=channel.channel_id) + '?.pvr',
            art_dict=dict(
                icon=icon,
                thumb=icon,
                fanart=fanart,
            ),
            info_dict=dict(
                plot=Menu.format_plot(channel),
                playcount=0,
                mediatype='video',
            ),
            stream_dict=dict(
                codec='h264',
                height=1080,
                width=1920,
            ),
            is_playable=True,
        )]

        if channel_data and channel_data.get('epg'):
            listing.append(
                kodiutils.TitleItem(
                    title=kodiutils.localize(30053, channel=channel_data.get('label')),  # TV Guide for {channel}
                    path=kodiutils.url_for('show_tvguide_channel', channel=channel_data.get('epg')),
                    art_dict=dict(
                        icon='DefaultAddonTvInfo.png',
                    ),
                    info_dict=dict(
                        plot=kodiutils.localize(30054, channel=channel_data.get('label')),  # Browse the TV Guide for {channel}
                    ),
                )
            )

        listing.append(kodiutils.TitleItem(
            title=kodiutils.localize(30055, channel=channel_data.get('label')),  # Catalog for {channel}
            path=kodiutils.url_for('show_catalog_channel', channel=key),
            art_dict=dict(
                icon='DefaultMovieTitle.png'
            ),
            info_dict=dict(
                plot=kodiutils.localize(30056, channel=channel_data.get('label')),  # Browse the Catalog for {channel}
            ),
        ))

        # Add YouTube channels
        if channel_data and kodiutils.get_cond_visibility('System.HasAddon(plugin.video.youtube)') != 0:
            for youtube in channel_data.get('youtube', []):
                listing.append(kodiutils.TitleItem(
                    title=kodiutils.localize(30206, label=youtube.get('label')),  # Watch {label} on YouTube
                    path=youtube.get('path'),
                    info_dict=dict(
                        plot=kodiutils.localize(30206, label=youtube.get('label')),  # Watch {label} on YouTube
                    )
                ))

        kodiutils.show_listing(listing, 30007, sort=['unsorted'])