main.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:YoutubeTV 作者: dude56987 项目源码 文件源码
def list_videos(category):
    """
    Create the list of playable videos in the Kodi interface.

    :param category: str
    """
    # Get the list of videos in the category.
    videos = get_videos(category)
    # Create a list for our items.
    listing = []
    # create playlists button to link to youtube playlist functionality
    listing.append(createButton(action=('channelPlaylists&channel='+category),\
        title='Playlists',thumb=(_resdir+'/media/playlist.png'),icon='',fanart=''))
    # show related channels button
    listing.append(createButton(action=('relatedChannels&value='+category),\
        title='Related Channels',thumb=(_basedir+'/icon.png'),icon='',fanart=''))
    # Iterate through videos.
    for video in videos:
        # Create a list item with a text label and a thumbnail image.
        list_item = xbmcgui.ListItem(label=video['name'])
        # Set additional info for the list item.
        list_item.setInfo('video', {'title': video['name'], 'genre': video['genre']})
        # 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': video['thumb'], 'icon': video['thumb'], 'fanart': video['thumb']})
        # Set 'IsPlayable' property to 'true'.
        # This is mandatory for playable items!
        list_item.setProperty('IsPlayable', 'true')
        # Create a URL for the plugin recursive callback.
        # Example: plugin://plugin.video.example/?action=play&video=http://www.vidsplay.com/vids/crab.mp4
        url = '{0}?action=play&video={1}'.format(_url, video['video'])
        # Add the list item to a virtual Kodi folder.
        # is_folder = False means that this item won't open any sub-list.
        is_folder = False
        # 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)
    # change the default view to thumbnails
    xbmc.executebuiltin('Container.SetViewMode(%d)' % 500)
    # Finish creating a virtual folder.
    xbmcplugin.endOfDirectory(_handle)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号