def build_profiles_listing(self, profiles, action, build_url):
"""
Builds the profiles list Kodi screen
:param profiles: list of user profiles
:type profiles: list
:param action: action paramter to build the subsequent routes
:type action: str
:param build_url: function to build the subsequent routes
:type build_url: fn
:returns: bool -- List could be build
"""
# init html parser for entity decoding
html_parser = HTMLParser()
# build menu items for every profile
for profile in profiles:
# load & encode profile data
enc_profile_name = profile.get('profileName', '').encode('utf-8')
unescaped_profile_name = html_parser.unescape(enc_profile_name)
profile_guid = profile.get('guid')
# build urls
url = build_url({'action': action, 'profile_id': profile_guid})
autologin_url = build_url({
'action': 'save_autologin',
'autologin_id': profile_guid,
'autologin_user': enc_profile_name})
# add list item
list_item = xbmcgui.ListItem(
label=unescaped_profile_name,
iconImage=profile.get('avatar'))
list_item.setProperty(
key='fanart_image',
value=self.default_fanart)
# add context menu options
auto_login = (
self.get_local_string(30053),
'RunPlugin(' + autologin_url + ')')
list_item.addContextMenuItems(items=[auto_login])
# add directory & sorting options
xbmcplugin.addDirectoryItem(
handle=self.plugin_handle,
url=url,
listitem=list_item,
isFolder=True)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_LABEL)
return xbmcplugin.endOfDirectory(handle=self.plugin_handle)
评论列表
文章目录