コード例 #1
0
 def endDirectory(self, contentType='addons', sortMethod=control.xDirSort.NoSort, category=None):
     control.content(syshandle, contentType)
     if category is not None:
         control.category(syshandle, category)
     if sortMethod is not control.xDirSort.NoSort:
         control.sortMethod(syshandle, sortMethod)
     control.directory(syshandle, cacheToDisc=True)
コード例 #2
0
 def endDirectory(self, contentType='addons', sortMethod=control.xDirSort.NoSort, category=None):
     control.content(syshandle, contentType)
     scrambled_eggs = control.setting('tv.tvtap.frytheeggs')
     if scrambled_eggs == '' or scrambled_eggs == 'true':
         control.sortMethod(syshandle, xbmcplugin.SORT_METHOD_LABEL)
     else:
         control.sortMethod(syshandle, sortMethod)
     if category is not None:
         control.category(syshandle, category)
     control.directory(syshandle, cacheToDisc=True)
コード例 #3
0
ファイル: swift.py プロジェクト: southpaw99/houseatreides
 def endDirectory(self,
                  contentType='addons',
                  sortMethod=control.xDirSort.NoSort,
                  category=None):
     control.content(syshandle, contentType)
     sort_clowns = control.setting('tv.swift.sorttheclowns')
     if sort_clowns == '' or sort_clowns == 'true':
         control.sortMethod(syshandle, xbmcplugin.SORT_METHOD_LABEL)
     else:
         control.sortMethod(syshandle, sortMethod)
     if category is not None:
         control.category(syshandle, category)
     control.directory(syshandle, cacheToDisc=True)
コード例 #4
0
ファイル: main.py プロジェクト: samuel384/plugin.video.brplay
def run(params):
    from resources.lib.modules import control

    params = params or {}

    control.log('[BRplay] - PARAMS: %s' % params)

    # Parameters
    action = params.get('action')

    meta = params.get('meta')

    try:
        meta_json = json.loads(meta) if meta else None
    except:
        control.log(traceback.format_exc(), control.LOGERROR)
        meta_json = {}

    # Actions
    if not action:
        from resources.lib.indexers import navigator, indexer
        syshandle = int(sys.argv[1])
        indexer.create_directory(navigator.root(), cache_to_disk=False)
        control.category(handle=syshandle, category=control.addonInfo('name'))

    elif action == 'settings':
        from resources.lib.indexers import navigator
        navigator.open_settings()

    elif action == 'clear':
        from resources.lib.indexers import navigator
        navigator.clear_cache()

    elif action == 'clearAuth':
        from resources.lib.indexers import navigator
        navigator.clear_credentials()

    elif action == 'refresh':
        from resources.lib.modules import control
        control.refresh()

    # Generic Tree

    elif action == 'generic':
        from resources.lib.indexers import indexer
        indexer.handle_route(meta_json)
コード例 #5
0
    def channel_directory(self, items):
        if items is None or len(items) == 0:
            control.idle()
            sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        try:
            isOld = False
            control.item().getArt('type')
        except:
            isOld = True

        refreshMenu = control.lang(32072).encode('utf-8')

        list_items = []

        for order, channel in enumerate(items):
            label = channel['name']
            meta = channel
            meta.update({'mediatype': channel['mediatype'] if 'mediatype' in channel else 'tvshow'})  # string - "video", "movie", "tvshow", "season", "episode" or "musicvideo"
            meta.update({'playcount': 0, 'overlay': 6})
            meta.update({'duration': channel['duration']}) if 'duration' in channel else None
            meta.update({'title': channel['title']}) if 'title' in channel else None
            meta.update({'tagline': channel['tagline']}) if 'tagline' in channel else None
            meta.update({'year': channel['year']}) if 'year' in channel else None

            meta.update({'sorttitle': meta['title']})
            meta.update({'title': meta['name']})

            sysmeta = urllib.quote_plus(json.dumps(meta))
            id_globo_videos = channel['id']
            brplayprovider = channel['brplayprovider'] if 'brplayprovider' in channel else None
            isFolder = channel['isFolder'] == 'true' if 'isFolder' in channel else False
            isPlayable = channel['playable'] == 'true' if 'playable' in channel else False

            url = channel['url'] if 'url' in channel else '%s?action=playlive&provider=%s&id_globo_videos=%s&isFolder=%s&meta=%s&t=%s' % (sysaddon, brplayprovider, id_globo_videos, isFolder, sysmeta, self.systime)

            cm = [(refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon)]

            if isOld is True:
                cm.append((control.lang2(19033).encode('utf-8'), 'Action(Info)'))

            item = control.item(label=label)

            fanart = channel['fanart']

            art = {'icon': channel['logo'], 'fanart': fanart}

            if 'poster' in channel:
                art.update({'poster': channel['poster']})
            if 'banner' in channel:
                art.update({'banner': channel['banner']})
            if 'clearart' in channel:
                art.update({'clearart': channel['clearart']})
            if 'clearlogo' in channel:
                art.update({'clearlogo': channel['clearlogo']})
            if 'landscape' in channel:
                art.update({'landscape': channel['landscape']})
            if 'thumb' in channel:
                art.update({'thumb': channel['thumb']})

            item.setArt(art)

            if 'logo' in channel and 'logo2' in channel:
                item.setProperty('Logo1', channel['logo'])
                item.setProperty('Logo2', channel['logo2'])
                item.setProperty('Initials1', channel['initials1'])
                item.setProperty('Initials2', channel['initials2'])

            if 'live' in channel:
                item.setProperty('Live', str(channel['live']))

            if 'gamedetails' in channel:
                item.setProperty('GameDetails', channel['gamedetails'])

            item.setProperty('Fanart_Image', fanart)

            if 'hd' not in channel or channel['hd'] == True:
                video_info = {'aspect': 1.78, 'width': 1280, 'height': 720}
            else:
                video_info = {'aspect': 1.78, 'width': 720, 'height': 480}

            item.addStreamInfo('video', video_info)

            item.addContextMenuItems(cm)
            item.setProperty('IsPlayable', 'false' if isFolder or not isPlayable else 'true')
            item.setInfo(type='video', infoLabels=meta)

            item.setContentLookup(False)

            if 'duration' in channel and channel['duration'] is not None:
                duration = float(meta['duration'])
                startdate = util.strptime_workaround(channel['dateadded'], '%Y-%m-%d %H:%M:%S') if 'dateadded' in channel else None
                offset = float(util.get_total_seconds(datetime.datetime.now() - startdate)) if startdate else 0
                item.setProperty('Progress', str((offset / duration) * 100) if duration else str(0))
                item.setProperty('totaltime', str(duration))

            # if not isFolder:
            #     item.setMimeType("application/vnd.apple.mpegurl")

            list_items.append((url, item, isFolder))

        # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_VIDEO_SORT_TITLE)
        # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_DATEADDED)
        # control.addSortMethod(int(sys.argv[1]), control.SORT_METHOD_LABEL_IGNORE_FOLDERS)

        control.addItems(syshandle, list_items)
        control.category(handle=syshandle, category=control.lang(32001).encode('utf-8'))

        content = 'LiveTV' if control.isJarvis else 'tvshows'

        control.content(syshandle, content)
        control.directory(syshandle, cacheToDisc=False)
コード例 #6
0
def create_directory(items, current=None, cache_to_disk=True):
    if current is None:
        current = {}

    succeeded = True
    custom_title = None

    try:
        media_types = {}
        content = None
        sort_methods = set()

        for data in items:
            label = data.get('label', '')

            if control.supports_offscreen:
                item = control.item(label=label, offscreen=True)
            else:
                item = control.item(label=label)

            art = data.get('art', {}) or {}
            item.setArt(art)

            properties = data.get('properties', {}) or {}
            item.setProperties(properties)

            item.setInfo(type='video',
                         infoLabels=control.filter_info_labels(data))

            cm = [(control.lang(32072).encode('utf-8'),
                   'RunPlugin(%s?action=refresh)' % sysaddon),
                  (control.lang(33501).encode('utf-8'),
                   'RunPlugin(%s?action=clear)' % sysaddon)]

            for menu in data.get('context_menu', []) or []:
                cm.append(menu)

            item.addContextMenuItems(cm)

            meta_string = urllib.quote_plus(json.dumps(data))
            url = data.get(
                'url',
                None) or '%s?action=generic&meta=%s' % (sysaddon, meta_string)

            is_playable = data.get('IsPlayable', False)
            is_folder = data.get('IsFolder', not is_playable)

            if is_playable:
                item.setProperty('IsPlayable', 'true')
            else:
                item.setProperty('IsPlayable', 'false')

            media_type = data.get('mediatype', 'None') or 'None'
            if media_type not in media_types:
                media_types[media_type] = 1
            else:
                media_types[media_type] = media_types[media_type] + 1

            sorts = data.get('sort', [])
            if sorts:
                try:
                    for sort in sorts:
                        sort_methods.add(sort)
                except TypeError:
                    sort_methods.add(sorts)

            if not content and data.get('content', None):
                content = data.get('content', None)

            if not custom_title:
                custom_title = data.get('custom_title', None)

            if data.get('setCast', None):
                item.setCast(data.get('setCast', None))

            control.addItem(handle=syshandle,
                            url=url,
                            listitem=item,
                            isFolder=is_folder)

        for sort in sort_methods:
            if isinstance(sort, tuple):
                control.addSortMethod(syshandle, sort[0], sort[1])
            else:
                control.addSortMethod(syshandle, sort)

        category = custom_title or current.get('label', None)
        if category:
            control.category(handle=syshandle, category=category)

        # content: files, songs, artists, albums, movies, tvshows, episodes, musicvideos
        if not content and media_types:
            media_type = max(media_types.iteritems(),
                             key=operator.itemgetter(1))[0]

            if media_type == 'movie':
                content = 'movies'

            elif media_type == 'tvshow':
                content = 'tvshows'

            elif media_type == 'episode':
                content = 'episodes'

            elif media_type == 'season':
                content = 'tvshows'

            elif media_type == 'musicvideo':
                content = 'musicvideos'

        if content and content != 'default':
            control.content(syshandle, content)

    except:
        control.log(traceback.format_exc(), control.LOGERROR)
        succeeded = False
    finally:
        control.directory(syshandle,
                          succeeded=succeeded,
                          updateListing=False,
                          cacheToDisc=cache_to_disk)
コード例 #7
0
    def channelDirectory(self, items):
        if items == None or len(items) == 0:
            control.idle()
            sys.exit()

        sysaddon = sys.argv[0]

        syshandle = int(sys.argv[1])

        addonPoster, addonBanner = control.addonPoster(), control.addonBanner()

        addonFanart, settingFanart = control.addonFanart(), control.setting(
            'fanart')

        try:
            isOld = False
            control.item().getArt('type')
        except:
            isOld = True

        isPlayable = 'true' if not 'plugin' in control.infoLabel(
            'Container.PluginName') else 'false'

        playbackMenu = control.lang(32063).encode('utf-8') if control.setting(
            'hosts.mode') == '2' else control.lang(32064).encode('utf-8')

        queueMenu = control.lang(32065).encode('utf-8')

        refreshMenu = control.lang(32072).encode('utf-8')

        infoMenu = control.lang(32101).encode('utf-8')

        for i in items:
            try:
                label = '[B]%s[/B] : %s (%s)' % (i['channel'].upper(),
                                                 i['title'], i['year'])
                sysname = urllib.quote_plus('%s (%s)' %
                                            (i['title'], i['year']))
                systitle = urllib.quote_plus(i['title'])
                imdb, tmdb, year = i['imdb'], i['tmdb'], i['year']

                meta = dict((k, v) for k, v in i.iteritems() if not v == '0')
                meta.update({
                    'code': imdb,
                    'imdbnumber': imdb,
                    'imdb_id': imdb
                })
                meta.update({'tmdb_id': tmdb})
                meta.update({'mediatype': 'movie'})
                meta.update({
                    'trailer':
                    '%s?action=trailer&name=%s' % (sysaddon, sysname)
                })
                #meta.update({'trailer': 'plugin://script.extendedinfo/?info=playtrailer&&id=%s' % imdb})
                meta.update({'playcount': 0, 'overlay': 6})
                try:
                    meta.update(
                        {'genre': cleangenre.lang(meta['genre'], self.lang)})
                except:
                    pass

                sysmeta = urllib.quote_plus(json.dumps(meta))

                url = '%s?action=play&title=%s&year=%s&imdb=%s&meta=%s&t=%s' % (
                    sysaddon, systitle, year, imdb, sysmeta, self.systime)
                sysurl = urllib.quote_plus(url)

                cm = []

                cm.append(
                    (queueMenu, 'RunPlugin(%s?action=queueItem)' % sysaddon))

                cm.append(
                    (refreshMenu, 'RunPlugin(%s?action=refresh)' % sysaddon))

                cm.append((playbackMenu,
                           'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' %
                           (sysaddon, sysurl, sysmeta)))

                if isOld == True:
                    cm.append((infoMenu, 'Action(Info)'))

                item = control.item(label=label)

                art = {}

                if 'poster2' in i and not i['poster2'] == '0':
                    art.update({
                        'icon': i['poster2'],
                        'thumb': i['poster2'],
                        'poster': i['poster2']
                    })
                elif 'poster' in i and not i['poster'] == '0':
                    art.update({
                        'icon': i['poster'],
                        'thumb': i['poster'],
                        'poster': i['poster']
                    })
                else:
                    art.update({
                        'icon': addonPoster,
                        'thumb': addonPoster,
                        'poster': addonPoster
                    })

                art.update({'banner': addonBanner})

                if settingFanart == 'true' and 'fanart' in i and not i[
                        'fanart'] == '0':
                    item.setProperty('Fanart_Image', i['fanart'])
                elif not addonFanart == None:
                    item.setProperty('Fanart_Image', addonFanart)

                item.setArt(art)
                item.addContextMenuItems(cm)
                item.setProperty('IsPlayable', isPlayable)
                item.setInfo(type='Video',
                             infoLabels=control.metadataClean(meta))

                video_streaminfo = {'codec': 'h264'}
                item.addStreamInfo('video', video_streaminfo)

                control.addItem(handle=syshandle,
                                url=url,
                                listitem=item,
                                isFolder=False)
            except:
                pass

        control.content(syshandle, 'files')
        control.category(syshandle, 'Channels')
        control.directory(syshandle, cacheToDisc=True)