当前位置: 首页>>代码示例>>Python>>正文


Python xbmcplugin.addDirectoryItems函数代码示例

本文整理汇总了Python中xbmcplugin.addDirectoryItems函数的典型用法代码示例。如果您正苦于以下问题:Python addDirectoryItems函数的具体用法?Python addDirectoryItems怎么用?Python addDirectoryItems使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了addDirectoryItems函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: listEpisodes

    def listEpisodes(self, items, addSortMethods=True):
        directoryItems = list()
        for item in items:
            if 'PrimaryAsset' not in item or 'Uri' not in item['PrimaryAsset'] or not item['PrimaryAsset']['Uri']:
                continue

            infoLabels = {
                'title': item['Title']
            }
            if 'Description' in item:
                infoLabels['plot'] = item['Description']
            if 'PrimaryBroadcastStartTime' in item and item['PrimaryBroadcastStartTime'] is not None:
                broadcastTime = self.parseDate(item['PrimaryBroadcastStartTime'])
                if broadcastTime:
                    infoLabels['date'] = broadcastTime.strftime('%d.%m.%Y')
                    infoLabels['aired'] = broadcastTime.strftime('%Y-%m-%d')
                    infoLabels['year'] = int(broadcastTime.strftime('%Y'))

            iconImage = item['PrimaryImageUri']
            listItem = xbmcgui.ListItem(item['Title'], iconImage=iconImage)
            listItem.setInfo('video', infoLabels)
            listItem.setProperty('Fanart_Image', iconImage)
            url = PATH + '?playVideo=' + item['Slug']
            listItem.setProperty('IsPlayable', 'true')
            listItem.addContextMenuItems(self.menuItems, False)
            directoryItems.append((url, listItem))

        xbmcplugin.addDirectoryItems(HANDLE, directoryItems)
        if addSortMethods:
            xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
            xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.endOfDirectory(HANDLE)
开发者ID:xbmc-danish-addons,项目名称:plugin.video.drnu,代码行数:32,代码来源:addon.py

示例2: getTabs

def getTabs(gturl, gtname):
        ilist = []
        url = gturl.replace(' ','%20')
        html = getRequest(url)
        html  = re.compile('<section class="category-content full">(.+?)</section', re.DOTALL).search(html).group(1)
        if '<li class="active">' in html:
           getShows(gturl, gtname)
           return

        cats  = re.compile('<a href="(.+?)" aria-label="(.+?)".+?</a', re.DOTALL).findall(html)
        for url,name in cats:
           try:
              name = cleanname(name)
              plot = name
              mode = 'GL'
              catname = gtname
              if gtname != name:  catname = catname+' - '+name
              u = '%s?url=%s&name=%s&mode=%s' % (sys.argv[0],qp(url), qp(catname), mode)
              liz=xbmcgui.ListItem(name, '','DefaultFolder.png', icon)
              liz.setInfo( 'Video', { "Title": name, "Plot": plot })
              liz.setProperty('fanart_image', addonfanart)
              liz.setProperty('IsPlayable', 'true')
              ilist.append((u, liz, False))
           except:
              pass
        xbmcplugin.addDirectoryItems(int(sys.argv[1]), ilist, len(ilist))
开发者ID:NEOhidra,项目名称:plugin.video.cbc,代码行数:26,代码来源:default.py

示例3: list_categories

def list_categories():
    """
    Create the list of categories in the Kodi interface.

    Returns:
        None
    """
    categories = get_categories()
    listing = []
    for category in categories:
        # Create a list item with a text label and a thumbnail image.
        list_item = xbmcgui.ListItem(label=FEEDS[category]['name'], thumbnailImage=FEEDS[category]['icon'])
        # set fanart
        my_addon = xbmcaddon.Addon('plugin.audio.dancarlin')
        #list_item.setProperty('fanart_image', my_addon.getAddonInfo('fanart'))
        list_item.setArt({'fanart': my_addon.getAddonInfo('fanart')})
        # Set additional info for the list item.
        list_item.setInfo('video', {'title': category, 'genre': 'news'})
        list_item.setInfo('audio', {'title': category, 'genre': 'news'})
        # Create a URL for the plugin recursive callback.
        # e.g., plugin://plugin.audio.dancarlin/?action=listing&category=common_sense
        url = '{0}?action=listing&category={1}'.format(_url, category)
        # is_folder = True means that this item opens a sub-list of lower level items.
        is_folder = True
        # Add our item to the listing as a 3-element tuple.
        listing.append((url, list_item, is_folder))
    # Add our listing to Kodi.
    xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
    # Add a sort method for the virtual folder items (alphabetically, ignore articles)
    xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
    # Finish creating a virtual folder.
    xbmcplugin.endOfDirectory(_handle)
开发者ID:izilly,项目名称:plugin.audio.dancarlin,代码行数:32,代码来源:main.py

示例4: list_episodes

    def list_episodes(self, episodes):
        if not episodes:
            self.display_error(30000)
            return

        items = []
        for episode in episodes:
            fanart = episode['image']

            info_labels = {
                'title': episode['title'],
                'plot' : episode['description'],
                'aired' : episode['broadcast_date_time'],
                'genre' : episode['program']['category']['name']
            }

            item = xbmcgui.ListItem(episode['title'], iconImage=fanart)
            item.setInfo('video', info_labels)
            item.setProperty('Fanart_Image', fanart)
            url = self._build_url({'play_video': episode['id']})
            item.setProperty('IsPlayable', 'true')
            items.append((url, item))

        xbmcplugin.addDirectoryItems(HANDLE, items)
        xbmcplugin.endOfDirectory(HANDLE)
开发者ID:tmelin,项目名称:plugin.video.tv4.se,代码行数:25,代码来源:addon.py

示例5: LIST

  def LIST(self, url):
    if Debug: self.LOG('LIST()')
    json = simplejson.loads(urllib.urlopen(url).read())
    for entry in json['videos']:
      id = entry['id']
      title = entry['title']
      description = entry['description']
      _duration = entry['duration']
      if _duration >= 3600 * 1000:
          duration = time.strftime('%H:%M:%S', time.gmtime(_duration / 1000))
      else:
        duration = time.strftime('%M:%S', time.gmtime(_duration / 1000))
      video = entry['cdn_asset_url']
      channel = entry['channel_name']
      thumbnail_version = entry['thumbnail_version']
      thumbnail = 'http://img1.newslook.com/images/dyn/videos/%s/%s/pad/324/231/%s.jpg' % (id, thumbnail_version, id)

      listitem = xbmcgui.ListItem(title, iconImage='DefaultVideo.png', thumbnailImage=thumbnail)
      listitem.setProperty('IsPlayable', 'true')
      listitem.setProperty('mimetype', 'video/mp4')
      listitem.setInfo(type='video',
                       infoLabels={'title' : title,
                                   'plot' : description,
                                   'duration': duration,
                                   })
      xbmcplugin.addDirectoryItems(int(sys.argv[1]), [(video, listitem, False)])
    # Content Type
    xbmcplugin.setContent(int(sys.argv[1]), 'movies')
    # Sort methods
    xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_NONE, label2Mask='%D')
    # End of directory...
    xbmcplugin.endOfDirectory(int(sys.argv[1]), True)
开发者ID:queeup,项目名称:plugin.video.newslook,代码行数:32,代码来源:addon.py

示例6: listVideos

    def listVideos(self, programCards):
        items = list()
        if 'Data' in programCards:
            programCards = programCards['Data']

        for programCard in programCards:
            if 'ProgramCard' in programCard:
                programCard = programCard['ProgramCard']
            if not 'PrimaryAssetUri' in programCard:
                continue

            infoLabels = self.createInfoLabels(programCard)

            imageAsset = self.api.getAsset('Image', programCard)
            if imageAsset:
                iconImage = imageAsset['Uri']
            else:
                iconImage = ''
            item = xbmcgui.ListItem(infoLabels['title'], iconImage=iconImage)
            item.setInfo('video', infoLabels)
            item.setProperty('Fanart_Image', iconImage)
            url = PATH + '?videoasset=' + programCard['PrimaryAssetUri'] + '&urn=' + programCard['Urn']
            item.setProperty('IsPlayable', 'true')
            items.append((url, item))

        xbmcplugin.addDirectoryItems(HANDLE, items)
        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_TITLE)
        xbmcplugin.endOfDirectory(HANDLE)
开发者ID:A61273,项目名称:plugin.video.drnu,代码行数:29,代码来源:addon.py

示例7: listVideos

def listVideos(tagId):
    
    listing = map(toListItem, loadVideoList(tagId))
    xbmcplugin.addDirectoryItems(_HANDLE, listing, len(listing))
    xbmcplugin.addSortMethod(_HANDLE, xbmcplugin.SORT_METHOD_DATEADDED)
    xbmcplugin.addSortMethod(_HANDLE, xbmcplugin.SORT_METHOD_LABEL)
    xbmcplugin.endOfDirectory(_HANDLE)
开发者ID:czoller,项目名称:werderkodi,代码行数:7,代码来源:main.py

示例8: ListShows

    def ListShows(self, html):
        self.log(u"", xbmc.LOGDEBUG)
        listItems = []

        try:
            soup = BeautifulSoup(html, selfClosingTags=[u'img'])
            episodes = soup.findAll(u'a', u"thumbnail-programme-link")

            for episode in episodes:
                self.AddEpisodeToList(listItems, episode)

            xbmcplugin.addDirectoryItems( handle=self.pluginHandle, items=listItems )
            xbmcplugin.endOfDirectory( handle=self.pluginHandle, succeeded=True )

            return True
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            if html is not None:
                msg = "html:\n\n%s\n\n" % html
                exception.addLogMessage(msg)

            # Error getting list of shows
            exception.addLogMessage(self.language(30049))
            # Error getting list of shows
            exception.process(severity = self.logLevel(xbmc.LOGERROR))
            return False
开发者ID:vmware,项目名称:workflowTools,代码行数:28,代码来源:rte.py

示例9: ListAvailable

    def ListAvailable(self, html):
        self.log(u"", xbmc.LOGDEBUG)
        listItems = []

        try:
            soup = BeautifulSoup(html, selfClosingTags=[u'img'])
            count = int(soup.find(u'meta', { u'name' : u"episodes_available"} )[u'content'])

            availableEpisodes = soup.findAll(u'a', u"thumbnail-programme-link")

            for index in range ( 0, count ):
                self.AddEpisodeToList(listItems, availableEpisodes[index])

            xbmcplugin.addDirectoryItems( handle=self.pluginHandle, items=listItems )
            xbmcplugin.endOfDirectory( handle=self.pluginHandle, succeeded=True )

            return True
        except (Exception) as exception:
            if not isinstance(exception, LoggingException):
                exception = LoggingException.fromException(exception)

            if html is not None:
                msg = "html:\n\n%s\n\n" % html
                exception.addLogMessage(msg)

            # Error getting count of available episodes
            exception.addLogMessage(self.language(30045))
            exception.process(self.language(30046), self.language(30045), self.logLevel(xbmc.LOGERROR))
            return False
开发者ID:vmware,项目名称:workflowTools,代码行数:29,代码来源:rte.py

示例10: GetMiroFeed

  def GetMiroFeed(self, url):
    if Debug: self.LOG('GetMiroFeed()')
    feedHtml = fetcher.fetch(url, CACHE_TIME)
    encoding = feedHtml.split('encoding="')[1].split('"')[0]
    feedHtml = feedHtml.decode(encoding, 'ignore').encode('utf-8')

    feed = feedparser.parse(feedHtml)
    for item in feed['items']:
      infoLabels = {}
      if item.link.startswith('http://www.miroguide.com/feeds/'):
        id = item.link.replace('http://www.miroguide.com/feeds/', '')
      else:
        id = re.findall('/(.+?).jpeg', item.thumbnail)[0]
      title = infoLabels['title'] = item.title.replace('&#39;', "'").replace('&amp;', '&').replace('&quot;', '"')
      if isinstance(title, str): # BAD: Not true for Unicode strings!
        try:
          title = infoLabels['title'] = title.encode('utf-8', 'replace') #.encode('utf-8')
        except:
          continue #skip this, it likely will bork
      # I put it here because above isinstance code not working well with some languages.
      title = infoLabels['title'] = title.encode('utf-8', 'replace') #.encode('utf-8')
      try:
        infoLabels['date'] = item.updated
      except:
        infoLabels['date'] = ''
      subtitle = infoLabels['date']
      soup = self.StripTags(item.description)#, convertEntities=BSS.HTML_ENTITIES
      try:
        infoLabels['plot'] = soup.contents[0]
      except:
        infoLabels['plot'] = item.description.encode('utf-8', 'ignore')
      thumb = item.thumbnail
      if thumb == '':
          thumb = __icon__
      feedUrl = item["summary_detail"]["value"].replace('amp;', '')
      feedUrl = feedUrl[feedUrl.find('url1=') + 5:]
      feedUrl = feedUrl[:feedUrl.find('&trackback1')].replace('%3A', ':')
      feddUrl = feedUrl.replace(' ', '%20')

      listitem = xbmcgui.ListItem(title, iconImage='DefaultVideo.png', thumbnailImage=thumb)
      if self._issubscripted(id):
        infoLabels['overlay'] = xbmcgui.ICON_OVERLAY_WATCHED
        contextmenu = [(__language__(30102), 'XBMC.RunPlugin(%s?action=unsubscribe&id=%s)' % \
                                                            (sys.argv[0], id))]
      else:
        infoLabels['overlay'] = xbmcgui.ICON_OVERLAY_NONE
        contextmenu = [(__language__(30101), 'XBMC.RunPlugin(%s?action=subscribe&id=%s&name=%s&feedurl=%s&thumbnail_url=%s&description=%s)' % \
                                                            (sys.argv[0], id, urllib.quote_plus(title), urllib.quote_plus(feedUrl), thumb, ''))]
      listitem.setInfo(type='video', infoLabels=infoLabels)
      listitem.addContextMenuItems(contextmenu, replaceItems=False)
      parameters = '%s?action=getfeed&url=%s' % (sys.argv[0], urllib.quote_plus(feedUrl))
      xbmcplugin.addDirectoryItems(int(sys.argv[1]), [(parameters, listitem, True)])
    # Sort methods and content type...
    xbmcplugin.setContent(int(sys.argv[1]), 'movie')
    xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)
    xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
    if infoLabels['date']:
      xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
    # End of directory...
    xbmcplugin.endOfDirectory(int(sys.argv[1]), True)
开发者ID:queeup,项目名称:plugin.video.miro,代码行数:60,代码来源:addon.py

示例11: START

 def START(self):
   if Debug: self.LOG('START()')
   category = []
   # If keys exist in miro.db show My Subscription directory.
   if db.keys() != list():
     if Debug: self.LOG('My Subscriptions directory activated.')
     category += [{'title':__language__(30201), 'url':'', 'action':'mysubscriptions'}, ]
   db.close()
   category += [{'title':__language__(30202), 'url':'https://www.miroguide.com/api/list_categories?datatype=json', 'action':'categories', 'filter':'category'},
                {'title':__language__(30203), 'url':'https://www.miroguide.com/api/list_languages?datatype=json', 'action':'categories', 'filter':'language'},
                {'title':__language__(30204), 'url':'http://feeds.feedburner.com/miroguide/new', 'action':'getmirofeed'},
                {'title':__language__(30205), 'url':'http://feeds.feedburner.com/miroguide/featured', 'action':'getmirofeed'},
                {'title':__language__(30206), 'url':'http://feeds.feedburner.com/miroguide/popular', 'action':'getmirofeed'},
                {'title':__language__(30207), 'url':'http://feeds.feedburner.com/miroguide/toprated', 'action':'getmirofeed'},
                {'title':__language__(30208), 'url':'https://www.miroguide.com/rss/tags/HD', 'action':'getmirofeed'},
                #{'title':__language__(30209), 'url':'https://www.miroguide.com/rss/search/', 'action':'getmirofeed'},
                ]
   for i in category:
     try:
       filter = i['filter']
     except:
       filter = ''
     listitem = xbmcgui.ListItem(i['title'], iconImage='DefaultFolder.png', thumbnailImage=__icon__)
     parameters = '%s?action=%s&url=%s&filter=%s' % \
                  (sys.argv[0], i['action'], urllib.quote_plus(i['url']), filter)
     xbmcplugin.addDirectoryItems(int(sys.argv[1]), [(parameters, listitem, True)])
   # Sort methods and content type...
   xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE)
   # End of directory...
   xbmcplugin.endOfDirectory(int(sys.argv[1]), True)
开发者ID:queeup,项目名称:plugin.video.miro,代码行数:30,代码来源:addon.py

示例12: GetSubscriptions

 def GetSubscriptions(self):
   if Debug: self.LOG('GetSubscriptions()')
   for k, v in db.iteritems():
     id = k
     name = v['name']
     feedUrl = v['url']
     if not feedUrl: continue
     try: thumb = v['thumbnail_url']
     except: pass
     summary = v['description']
     listitem = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=thumb)
     listitem.setInfo(type='video',
                      infoLabels={'title' : name,
                                  'plot' : summary,
                                  })
     contextmenu = [(__language__(30102), 'XBMC.RunPlugin(%s?action=unsubscribe&id=%s)' % \
                                                         (sys.argv[0], id))]
     listitem.addContextMenuItems(contextmenu, replaceItems=False)
     parameters = '%s?action=getfeed&url=%s' % (sys.argv[0], urllib.quote_plus(feedUrl))
     xbmcplugin.addDirectoryItems(int(sys.argv[1]), [(parameters, listitem, True)])
   db.close()
   # Sort methods and content type...
   xbmcplugin.setContent(int(sys.argv[1]), 'movies')
   xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED)
   xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_VIDEO_TITLE)
   # End of directory...
   xbmcplugin.endOfDirectory(int(sys.argv[1]), True)
开发者ID:queeup,项目名称:plugin.video.miro,代码行数:27,代码来源:addon.py

示例13: list_categories

def list_categories():

    f = urllib2.urlopen('http://api.m.panda.tv/ajax_get_all_subcate?__version=1.0.5.1098&__plat=iOS')

    obj = json.loads(f.read())

    listing=[]

    list_item = xbmcgui.ListItem(label='全部直播')
    # list_item.setProperty('fanart_image', game['img'])
    url='{0}?action=all'.format(_url)
    listing.append((url, list_item, True))

    for game in obj['data']:
        list_item = xbmcgui.ListItem(label=game['cname'], thumbnailImage=game['img'])
        list_item.setProperty('fanart_image', game['img'])
        url='{0}?action=room_list&game_id={1}'.format(_url, game['ename'])

        is_folder=True
        listing.append((url, list_item, is_folder))

    xbmcplugin.addDirectoryItems(_handle,listing,len(listing))
    #xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
    # Finish creating a virtual folder.
    xbmcplugin.endOfDirectory(_handle)
开发者ID:caasiu,项目名称:xbmc-addons-chinese,代码行数:25,代码来源:addon.py

示例14: list_categories

def list_categories(offset):
    #f=urllib2.urlopen('http://www.douyutv.com/directory')
    #rr=BeautifulSoup(f.read())
    rr=BeautifulSoup(requests.get('http://www.douyutv.com/directory',headers=headers).text)
    catel=rr.findAll('a',{'class':'thumb'},limit=offset+PAGE_LIMIT+1)
    rrr=[(x['href'], x.p.text,x.img['data-original']) for x in catel]
    offset=int(offset)
    if offset+PAGE_LIMIT<len(rrr):
      rrr=rrr[offset:offset+PAGE_LIMIT]
      nextpageflag=True
    else:
      rrr=rrr[offset:]
      nextpageflag=False
    listing=[]
    for classname,textinfo,img in rrr:
        list_item=xbmcgui.ListItem(label=textinfo,thumbnailImage=img)
        #list_item.setProperty('fanart_image',img)
        url=u'{0}?action=listing&category={1}&offset=0'.format(_url,classname)
        is_folder=True
        listing.append((url,list_item,is_folder))
    if nextpageflag==True:
        list_item=xbmcgui.ListItem(label=NEXT_PAGE)
        url=u'{0}?offset={1}'.format(_url,str(offset+PAGE_LIMIT))
        is_folder=True
        listing.append((url,list_item,is_folder))
    xbmcplugin.addDirectoryItems(_handle,listing,len(listing))
    #xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
    # Finish creating a virtual folder.
    xbmcplugin.endOfDirectory(_handle) 
开发者ID:yangqian,项目名称:plugin.video.douyutv2,代码行数:29,代码来源:addon.py

示例15: getAtoZ

def getAtoZ(gzurl):
    setContent("files")
    ilist = []
    azheaders = defaultHeaders
    azheaders["X-Requested-With"] = "XMLHttpRequest"
    pg = getRequest("http://video.pbs.org/programs/list", None, azheaders)
    a = json.loads(pg)
    for y in gzurl:
        try:
            b = a[y]
            for x in b:
                fullname = h.unescape("%s [%s]" % (x["title"], x["video_count"])).encode(UTF8)
                name = h.unescape(x["title"]).encode(UTF8)
                plot = h.unescape(x["producer"]).encode(UTF8)
                url = ("program/%s" % (x["slug"])).encode(UTF8)
                mode = "GV"
                u = "%s?url=%s&name=%s&mode=%s" % (sys.argv[0], qp(url), qp(name), mode)
                liz = xbmcgui.ListItem(fullname, "", icon, None)
                #            liz.setInfo( 'Video', { "Title": name, "Plot": plot })
                liz.setProperty("Fanart_Image", addonfanart)
                ilist.append((u, liz, True))
        except:
            pass
    xbmcplugin.addDirectoryItems(int(sys.argv[1]), ilist, len(ilist))
    endView("default_view")
开发者ID:NEOhidra,项目名称:plugin.video.thinktv,代码行数:25,代码来源:default.py


注:本文中的xbmcplugin.addDirectoryItems函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。