Python xbmcgui 模块,html() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用xbmcgui.html()

项目:plugin.video.auvio    作者:rickybiscus    | 项目源码 | 文件源码
def program_to_kodi_item(node):

    """
    Convert a show API object to a kodi list item
    """

    id = int(node.get('id',0))

    li = {
        'label':    node.get('name',''),
        'url':      common.plugin.get_url(action='list_medias',filter_medias='program_medias_recent',program_id=id),
        #'thumb':    image, # Item thumbnail
        #'fanart':   image,
        'info': {
            'video': { ##http://romanvm.github.io/Kodistubs/_autosummary/xbmcgui.html#xbmcgui.ListItem.setInfo
                #'plot':         node.get('description',''),#Long Description
                #'plotoutline':  node.get('description',''),#Short Description
            }
        }

    }
    return li
项目:kodi-addons    作者:leonardoxiao    | 项目源码 | 文件源码
def ajax_get_video(acp_pid, acp_currpage):
    print("ajax_get_video({0}, {1})".format(acp_pid, acp_currpage))

    url = 'http://www.fullmatchesandshows.com/wp-admin/admin-ajax.php'
    user_agent = 'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'
    headers = { 'User-Agent' : user_agent, 'Content-type': 'application/x-www-form-urlencoded; charset=UTF-8', 'X-Requested-With': 'XMLHttpRequest' }

    params = urllib.urlencode({'acp_currpage': acp_currpage, 'acp_pid': acp_pid, 'acp_shortcode': 'acp_shortcode', 'action': 'pp_with_ajax'})
    req = urllib2.Request(url, params, headers)
    con = urllib2.urlopen(req)
    content = con.read()
    print("content={0}".format(content))
    #soup = BeautifulSoup(con.read(), "html.parser")
    soup = BeautifulSoup(content, "html.parser")
    script = soup.find("script")
    if script != None and script.has_attr('data-config'):
        url = script['data-config']
        return url

    return None
项目:addon    作者:alfa-addon    | 项目源码 | 文件源码
def set_infolabels(listitem, item, player=False):
    """
    Metodo para pasar la informacion al listitem (ver tmdb.set_InfoLabels() )
    item.infoLabels es un dicionario con los pares de clave/valor descritos en:
    http://mirrors.xbmc.org/docs/python-docs/14.x-helix/xbmcgui.html#ListItem-setInfo
    @param listitem: objeto xbmcgui.ListItem
    @type listitem: xbmcgui.ListItem
    @param item: objeto Item que representa a una pelicula, serie o capitulo
    @type item: item
    """
    if item.infoLabels:
        if 'mediatype' not in item.infoLabels:
            item.infoLabels['mediatype'] = item.contentType
        listitem.setInfo("video", item.infoLabels)

    if player and not item.contentTitle:
        if item.fulltitle:
            listitem.setInfo("video", {"Title": item.fulltitle})
        else:
            listitem.setInfo("video", {"Title": item.title})

    elif not player:
        listitem.setInfo("video", {"Title": item.title})
项目:YoutubeTV    作者:dude56987    | 项目源码 | 文件源码
def grabWebpage(self,url):
        '''
        Download the url, strip line endings, and return a string.
        '''
        userAgent=addonObject.getSetting('userAgent')
        header = {'User-Agent': userAgent,
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
        'Accept-Encoding': 'none',
        'Accept-Language': 'en-US,en;q=0.8',
        'Connection': 'keep-alive'}
        requestObject = urllib2.Request(url,headers=header)
        # get the youtube users webpage
        try:
            # try to download the webpage
            webpageText=urllib2.urlopen(requestObject)
        except:
            popup('YoutubeTV', ('Failed to load webpage "'+str(url)+'"'))
            # download failed, return blank string
            return str()
        temp=''
        for line in webpageText:
            # mash everything into a string because they use code obscification
            # also strip endlines to avoid garbage
            temp+=(line.strip())
        return temp
项目:pelisalacarta-ce    作者:pelisalacarta-ce    | 项目源码 | 文件源码
def set_infolabels(listitem, item, player=False):
    """
    Metodo para pasar la informacion al listitem (ver tmdb.set_InfoLabels() )
    item.infoLabels es un dicionario con los pares de clave/valor descritos en:
    http://mirrors.xbmc.org/docs/python-docs/14.x-helix/xbmcgui.html#ListItem-setInfo
    @param listitem: objeto xbmcgui.ListItem
    @type listitem: xbmcgui.ListItem
    @param item: objeto Item que representa a una pelicula, serie o capitulo
    @type item: item
    """
    if item.infoLabels:
        if 'mediatype' not in item.infoLabels:
            item.infoLabels['mediatype'] = item.contentType
        listitem.setInfo("video", item.infoLabels)

    if player and not item.contentTitle:
        if item.fulltitle:
            listitem.setInfo("video", {"Title": item.fulltitle})
        else:
            listitem.setInfo("video", {"Title": item.title})

    elif not player:
        listitem.setInfo("video", {"Title": item.title})

    # Añadido para Kodi Krypton (v17)
    if config.get_platform(True)['num_version'] >= 17.0:
        listitem.setArt({"poster": item.thumbnail})
项目:kodi-addons    作者:leonardoxiao    | 项目源码 | 文件源码
def get_categories():
    """
    Get the list of match categories.
    Here you can insert some parsing code that retrieves
    the list of match categories (e.g. 'Movies', 'TV-shows', 'Documentaries' etc.)
    from some site or server.
    :return: list
    """
    req = urllib2.Request(URL, headers=HEADERS) 
    con = urllib2.urlopen( req )
    content = con.read()
    soup = BeautifulSoup(content, "html.parser")

    items = []
    main_menu_1 = soup.find("ul", {"id":"menu-main-menu-1"})
    for li in main_menu_1.find_all("li"):
        item = {}
        if li.text == "HOME":
            item['name'] = 'Latest Hightlights and Full Matches'
            item['url'] = li.find("a")['href']
            items.append(item)
        else:
            sub_menu = li.find("ul", class_="sub-menu")
            if sub_menu == None:
                # We will skip the rest (live football, humor etc) for now
                continue
            else:
                for sub_item in sub_menu.find_all("li"):
                    item = {}
                    item['name'] = sub_item.text
                    item['url'] = sub_item.find("a")['href']
                    items.append(item)

    return items
项目:crossplatform_iptvplayer    作者:j00zek    | 项目源码 | 文件源码
def prepareKODIurlsList(urlsList, videoName):
    exec(urlsList)
    for item in UrlsList:
        list_item = xbmcgui.ListItem(label = item['name'])
        #list_item.setArt({'thumb': VIDEOS[category][0]['thumb'],
        #          'icon': VIDEOS[category][0]['thumb'],
        #          'fanart': VIDEOS[category][0]['thumb']})
        # Set additional info for the list item.
        # Here we use a category name for both properties for for simplicity's sake.
        list_item.setInfo('video', {'title': videoName}) # http://mirrors.xbmc.org/docs/python-docs/15.x-isengard/xbmcgui.html#ListItem-setInfo
        list_item.setProperty('IsPlayable', 'true')
        myID = item['id']
        myUrl = item['url']
        myLevel = ADDON.getSetting("currenLevel")
        is_folder = False
        url = get_url(action = 'playUrl',
                      id = myID,
                      level = myLevel,
                      urlNeedsResolve=item['urlNeedsResolve'],
                      url=myUrl,
                      name=videoName) # Create a URL for a plugin recursive call.
        if ADDON.getSetting("PlayerMode") == "2":
            list_item.setArt({'thumb': xbmc.translatePath('special://home/addons/plugin.video.IPTVplayer/resources/icons/download.png')})
        xbmcplugin.addDirectoryItem(ADDON_handle, url, list_item, is_folder)
        myLog('action=playUrl id=%s level=%s' % (myID,myLevel))
        # Add a sort method for the virtual folder items (alphabetically, ignore articles)
        #xbmcplugin.addSortMethod(ADDON_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
        # Finish creating a virtual folder.

#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ### MAIN FUNCTION ###
项目:YoutubeTV    作者:dude56987    | 项目源码 | 文件源码
def grabChannelMetadata(self,channel):
        '''
        Takes a channel in the form of /user/username or /channel/hashvalue
        as a string. Downloads the webpage of the channel into the cache.
        Then reads the channels metadata into the channelCache for later
        use.
        '''
        # if the channel timer has expired or the channel does not
        # yet exist in the cache we need to update the channel data
        if self.checkTimer(channel+':meta','channelMetadataDelay') or\
        channel not in self.channelCache.names:
            # if channel is not in the cache then grab info from the website
            ##############
            # user channel information can be found by downloading the
            # user channel page with
            #"https://youtube.com"userName
            channelPage=self.cacheWebpage("https://www.youtube.com"+channel)
            # jerk out the banner image from the downloaded user webpage
            try:
                temp=channelPage.split('.hd-banner-image {background-image: url(//')
                temp=temp[1]
                temp=temp.split(');')
                # append https to the picture so it will work
                fanArt="https://"+temp[0]
            except:
                # if this does not work set the fanart to none
                fanArt='none'
            # split the page based on tag opening
            channelPage=channelPage.split("<")
            for tag in channelPage:
                # the channels metadata is stored in a image tag for the users
                # profile picture, so search for
                #'class="channel-header-profile-image"'
                if 'class="channel-header-profile-image"' in tag:
                    # inside this string you will have two important variables
                    # - first src="" will have the icon you should use for the channel
                    # - second title="" will have the human readable channel title
                    # you should store these things in the cache somehow to use them
                    # when rendering the channels view
                    # grab text in src attribute between parathenesis
                    icon=tag.split('src="')
                    icon=icon[1].split('"')
                    icon=icon[0]
                    # if a generated channel uses the other wierd icon format
                    if icon[:2]=='//':
                        icon='https:'+icon
                    # grab text in title attribute for channel title
                    title=tag.split('title="')
                    title=title[1].split('"')
                    title=title[0]
                    # clean html entities from title
                    title=self.cleanText(title)
                    # add channel information to the channel cache
                    tempChannelCache=dict()
                    # add title and icon
                    tempChannelCache['title']=title
                    tempChannelCache['icon']=icon
                    tempChannelCache['fanArt']=fanArt
                    self.channelCache.saveValue(channel,tempChannelCache)
项目:kodi-addons    作者:leonardoxiao    | 项目源码 | 文件源码
def get_video(video):
    """
    Get the option of a match.
    Here you can insert some parsing code that retrieves
    the list of videostreams in a given category from some site or server.

    :param video: url for the data in JSON
    :  there are 2 types: JSON or URL that we need to navigate to get the JSON link
    :return: video url
    """
    print("=====video_url={0}".format(video))

    if video[:2] == '//':
        video = 'http:' + video
    print("=====JSON_URL={0}".format(video))

    # JSON
    req = urllib2.Request(video, headers=HEADERS) 
    con = urllib2.urlopen( req )
    data = json.loads(con.read())

    title = data['settings']['title']
    duration = data['duration']

    content = data['content']
    if content.has_key('poster'):
        thumbnail = content['poster']
    src = content['media']['f4m']

    # XML
    print("=====media_f4m={0}".format(src))
    req = urllib2.Request(src, headers=HEADERS) 
    con = urllib2.urlopen( req )
    soup = BeautifulSoup(con.read(), "html.parser")

    base_url = soup.find('baseurl').text
    for media in soup.find_all("media"):
        media_url = media['url']
        tbr = media['bitrate']
        #width = media['width']
        #height = media['height']

        url = '{0}/{1}'.format(base_url, media_url)
        break

    return url
项目:kodi-addons    作者:leonardoxiao    | 项目源码 | 文件源码
def get_matches(content):
    """
    Get the list of videofiles/streams.
    Here you can insert some parsing code that retrieves
    the list of videostreams in a given category from some site or server.

    :param category: str
    :return: list
    """
    items = []

    soup = BeautifulSoup(content, "html.parser")
    for td_block in soup.find_all("div", class_=re.compile("^td_module_mx\d+")):
        #print("td_block={0}".format(td_block))
        if td_block.find("img") is None:
            continue

        item = {}
        #item['thumb'] = td_block.find("img", itemprop="image")['src']
        item['thumb'] = td_block.find("img")['src']
        #item['name'] = td_block.find("h3", itemprop="name").text
        item['name'] = td_block.find("h3").text
        #item['video'] = td_block.find("a", itemprop="url")['href']
        item['video'] = td_block.find("a")['href']
        #item['date'] = td_block.find("time", itemprop="dateCreated").text
        item['genre'] = 'Soccer'
        items.append(item)

    for td_block in soup.find_all("div", class_="td-block-span4"):
        print("td_block={0}".format(td_block))
        item = {}
        #item['thumb'] = td_block.find("img", itemprop="image")['src']
        item['thumb'] = td_block.find("img")['src']
        #item['name'] = td_block.find("h3", itemprop="name").text
        item['name'] = td_block.find("h3").text
        #item['video'] = td_block.find("a", itemprop="url")['href']
        item['video'] = td_block.find("a")['href']
        #item['date'] = td_block.find("time", itemprop="dateCreated").text
        item['genre'] = 'Soccer'
        items.append(item)

    return items
项目:kodi-addons    作者:leonardoxiao    | 项目源码 | 文件源码
def list_categories():
    """
    Create the list of video categories in the Kodi interface.
    """
    # Get video categories
    categories = get_categories()
    # Create a list for our items.
    listing = []
    # Iterate through categories
    for category in categories:
        category_name = category['name']
        category_url = category['url']
        # Create a list item with a text label and a thumbnail image.
        list_item = xbmcgui.ListItem(label=category_name, thumbnailImage=THUMBNAIL)
        # Set graphics (thumbnail, fanart, banner, poster, landscape etc.) for the list item.
        # Here we use the same image for all items for simplicity's sake.
        # In a real-life plugin you need to set each image accordingly.
        list_item.setArt({'thumb': THUMBNAIL,
                          'icon': THUMBNAIL,
                          'fanart': THUMBNAIL})
        # Set additional info for the list item.
        # Here we use a category name for both properties for for simplicity's sake.
        # setInfo allows to set various information for an item.
        # For available properties see the following link:
        # http://mirrors.xbmc.org/docs/python-docs/15.x-isengard/xbmcgui.html#ListItem-setInfo
        list_item.setInfo('video', {'title': category_name, 'genre': category_name})
        # Create a URL for the plugin recursive callback.
        # Example: plugin://plugin.video.example/?action=listing&category=Animals
        url = '{0}?action=list&category_name={1}&category_url={2}'.format(_url, category_name, category_url)
        # 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.
    # Large lists and/or slower systems benefit from adding all items at once via addDirectoryItems
    # instead of adding one by ove via addDirectoryItem.
    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)
    xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_NONE)
    # Finish creating a virtual folder.
    xbmcplugin.endOfDirectory(_handle)