main.py 文件源码

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

项目:plugin.video.areena 作者: hirsivaja 项目源码 文件源码
def list_streams(listing, streams, offset_url, item_limit=25):
    """
    Create the list of playable streams in the Kodi interface.
    :param listing: list for the streams. Can include some fixed elements
    :param streams: json of streams to list
    :param offset_url: url that opens next page of streams
    :param item_limit: maximum number of items per page
    :return: None
    """
    # Iterate through the streams.
    for stream in streams:
        list_item = create_list_item_from_stream(stream)
        if list_item is None:
            continue
        # 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&stream={1}'.format(_url, stream['id'])
        # 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))
    if len(listing) >= item_limit:
        list_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format(
            get_color('menuItemColor'), get_translation(32008)))
        listing.append((offset_url, list_item, True))
    # 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)
    # Finish creating a virtual folder.
    xbmcplugin.endOfDirectory(_handle)
    xbmcplugin.setContent(_handle, 'movies')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号