def list_matches(videos):
"""
Create the list of matches in the Kodi interface.
"""
print("=====list_matches()")
# Create a list for our items.
listing = []
# 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'])
if video['video'] == None:
# Non-video item: next page
url = video['url']
list_item.setProperty('IsPlayable', 'false')
# Add the list item to a virtual Kodi folder.
is_folder = True
else:
# 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']})
# Create a URL for the plugin recursive callback.
url = u'{0}?action=view&match={1}'.format(_url, video['video'])
# Set 'IsPlayable' property to 'true'.
# This is mandatory for playable items!
list_item.setProperty('IsPlayable', 'true')
# 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)
xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_NONE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
评论列表
文章目录