Example #1
0
    def list_youtube(channels=None):
        """Construct a list of youtube ListItems, either for Live TV or the TV Guide listing"""

        youtube_items = []

        if not has_addon('plugin.video.youtube') or not get_setting_bool(
                'showyoutube', default=True):
            return youtube_items

        for channel in CHANNELS:
            if channels and channel.get('name') not in channels:
                continue

            art_dict = {}

            # Try to use the white icons for thumbnails (used for icons as well)
            if has_addon('resource.images.studios.white'):
                art_dict[
                    'thumb'] = 'resource://resource.images.studios.white/{studio}.png'.format(
                        **channel)
            else:
                art_dict['thumb'] = 'DefaultTags.png'

            for youtube in channel.get('youtube', []):
                path = youtube_to_plugin_url(youtube['url'])
                label = localize(30143, **youtube)  # Channel on YouTube
                # A single Live channel means it is the entry for channel's TV Show listing, so make it stand out
                if channels and len(channels) == 1:
                    label = '[B]%s[/B]' % label
                plot = localize(30144, **youtube)  # Watch on YouTube
                # NOTE: Playcount is required to not have live streams as "Watched"
                info_dict = dict(title=label,
                                 plot=plot,
                                 studio=channel.get('studio'),
                                 mediatype='video',
                                 playcount=0)

                context_menu = [(
                    localize(30413),  # Refresh menu
                    'RunPlugin(%s)' %
                    url_for('delete_cache',
                            cache_file='channel.{channel}.json'.format(
                                channel=channel)),
                )]

                youtube_items.append(
                    TitleItem(
                        label=label,
                        path=path,
                        art_dict=art_dict,
                        info_dict=info_dict,
                        context_menu=context_menu,
                        is_playable=False,
                    ))

        return youtube_items
    def get_channel_items(self, date=None, channel=None):
        """Offer a menu to select the channel"""
        if date:
            now = datetime.now(dateutil.tz.tzlocal())
            epg = self.parse(date, now)
            datelong = localize_datelong(epg)

        channel_items = []
        for chan in CHANNELS:
            # Only some channels are supported
            if not chan.get('has_tvguide'):
                continue

            # If a channel is requested, stop processing if it is no match
            if channel and channel != chan.get('name'):
                continue

            art_dict = {}

            # Try to use the white icons for thumbnails (used for icons as well)
            if has_addon('resource.images.studios.white'):
                art_dict[
                    'thumb'] = 'resource://resource.images.studios.white/{studio}.png'.format(
                        **chan)
            else:
                art_dict['thumb'] = 'DefaultTags.png'

            if date:
                label = chan.get('label')
                path = url_for('tvguide', date=date, channel=chan.get('name'))
                plot = '[B]%s[/B]\n%s' % (datelong, localize(30302, **chan))
            else:
                label = '[B]%s[/B]' % localize(30303, **chan)
                path = url_for('tvguide_channel', channel=chan.get('name'))
                plot = '%s\n\n%s' % (localize(
                    30302, **chan), self.live_description(chan.get('name')))

            context_menu = [(
                localize(30413),  # Refresh menu
                'RunPlugin(%s)' %
                url_for('delete_cache',
                        cache_file='channel.{channel}.json'.format(
                            channel=chan.get('name'))),
            )]

            channel_items.append(
                TitleItem(
                    label=label,
                    path=path,
                    art_dict=art_dict,
                    context_menu=context_menu,
                    info_dict=dict(plot=plot, studio=chan.get('studio')),
                ))
        return channel_items
Example #3
0
 def push_upnext(self, info):
     ''' Push episode info to Up Next service add-on'''
     if has_addon('service.upnext') and get_setting('useupnext',
                                                    'true') == 'true':
         next_info = self._apihelper.get_upnext(info)
         if next_info:
             from binascii import hexlify
             from json import dumps
             data = [to_unicode(hexlify(dumps(next_info).encode()))]
             sender = '%s.SIGNAL' % addon_id()
             notify(sender=sender, message='upnext_data', data=data)
def index():
    """ Show the main menu """
    listing = [
        TitleItem(
            title=localize(30010),  # A-Z
            path=plugin.url_for(iptv_play),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon()),
            info_dict=dict(plot=localize(30228), ),
            is_playable=True),
        TitleItem(
            title=localize(30011),  # A-Z
            path=plugin.url_for(browse_product, 'discover'),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon())),
        TitleItem(
            title=localize(30012),  # A-Z
            path=plugin.url_for(
                browse_collection,
                'playlists::d554f1ca-5a8a-4d5c-a562-419185d57979'),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon())),
        TitleItem(
            title=localize(30013),  # A-Z
            path=plugin.url_for(browse_product, 'events'),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon()))
    ]

    if has_addon('plugin.video.youtube'):
        listing.append(
            TitleItem(
                title='YouTube',  # A-Z
                path=
                'plugin://plugin.video.youtube/channel/UCblfuW_4rakIf2h6aqANefA/',
                art_dict=dict(icon='DefaultMovieTitle.png',
                              fanart=addon_fanart(),
                              poster=addon_icon())))

    listing.append(
        TitleItem(
            title=localize(30014),  # A-Z
            path=plugin.url_for(search),
            art_dict=dict(icon='DefaultMovieTitle.png',
                          fanart=addon_fanart(),
                          poster=addon_icon())))

    show_listing(listing, content='videos', sort=['unsorted'])
 def push_upnext(self):
     """Push episode info to Up Next service add-on"""
     if has_addon('service.upnext') and get_setting_bool(
             'useupnext', default=True) and self.isPlaying():
         info_tag = self.getVideoInfoTag()
         next_info = self.apihelper.get_upnext(
             dict(
                 program=to_unicode(info_tag.getTVShowTitle()),
                 playcount=info_tag.getPlayCount(),
                 rating=info_tag.getRating(),
                 path=self.path,
                 runtime=self.total,
             ))
         if next_info:
             from base64 import b64encode
             from json import dumps
             data = [to_unicode(b64encode(dumps(next_info).encode()))]
             sender = '{addon_id}.SIGNAL'.format(addon_id=addon_id())
             notify(sender=sender, message='upnext_data', data=data)
    def list_channels(self, channels=None, live=True):
        ''' Construct a list of channel ListItems, either for Live TV or the TV Guide listing '''
        from tvguide import TVGuide
        _tvguide = TVGuide()

        channel_items = []
        for channel in CHANNELS:
            if channels and channel.get('name') not in channels:
                continue

            context_menu = []
            art_dict = dict()

            # Try to use the white icons for thumbnails (used for icons as well)
            if has_addon('resource.images.studios.white'):
                art_dict['thumb'] = 'resource://resource.images.studios.white/{studio}.png'.format(**channel)
            else:
                art_dict['thumb'] = 'DefaultTags.png'

            if not live:
                path = url_for('channels', channel=channel.get('name'))
                label = channel.get('label')
                plot = '[B]%s[/B]' % channel.get('label')
                is_playable = False
                info_dict = dict(title=label, plot=plot, studio=channel.get('studio'), mediatype='video')
                stream_dict = []
            elif channel.get('live_stream') or channel.get('live_stream_id'):
                if channel.get('live_stream_id'):
                    path = url_for('play_id', video_id=channel.get('live_stream_id'))
                elif channel.get('live_stream'):
                    path = url_for('play_url', video_url=channel.get('live_stream'))
                label = localize(30141, **channel)  # Channel live
                playing_now = _tvguide.playing_now(channel.get('name'))
                if playing_now:
                    label += ' [COLOR yellow]| %s[/COLOR]' % playing_now
                # A single Live channel means it is the entry for channel's TV Show listing, so make it stand out
                if channels and len(channels) == 1:
                    label = '[B]%s[/B]' % label
                is_playable = True
                if channel.get('name') in ['een', 'canvas', 'ketnet']:
                    if get_setting('showfanart', 'true') == 'true':
                        art_dict['fanart'] = self.get_live_screenshot(channel.get('name', art_dict.get('fanart')))
                    plot = '%s\n\n%s' % (localize(30142, **channel), _tvguide.live_description(channel.get('name')))
                else:
                    plot = localize(30142, **channel)  # Watch live
                # NOTE: Playcount is required to not have live streams as "Watched"
                info_dict = dict(title=label, plot=plot, studio=channel.get('studio'), mediatype='video', playcount=0, duration=0)
                stream_dict = dict(duration=0)
                context_menu.append((
                    localize(30413),
                    'RunPlugin(%s)' % url_for('delete_cache', cache_file='channel.%s.json' % channel)
                ))
            else:
                # Not a playable channel
                continue

            channel_items.append(TitleItem(
                title=label,
                path=path,
                art_dict=art_dict,
                info_dict=info_dict,
                stream_dict=stream_dict,
                context_menu=context_menu,
                is_playable=is_playable,
            ))

        return channel_items