def add_next_button(self, listtotal):
# adds a next button if needed
params = self.params
if listtotal > self.offset + self.limit:
params["offset"] = self.offset + self.limit
url = "plugin://plugin.audio.spotify/"
for key, value in params.iteritems():
if key == "action":
url += "?%s=%s" % (key, value[0])
elif key == "offset":
url += "&%s=%s" % (key, value)
else:
url += "&%s=%s" % (key, value[0])
li = xbmcgui.ListItem(
xbmc.getLocalizedString(33078),
path=url,
iconImage="DefaultMusicAlbums.png"
)
li.setProperty('do_not_analyze', 'true')
li.setProperty('IsPlayable', 'false')
xbmcplugin.addDirectoryItem(handle=self.addon_handle, url=url, listitem=li, isFolder=True)
python类addDirectoryItem()的实例源码
def addOfflineMediaFile(self,offlinefile):
listitem = xbmcgui.ListItem(offlinefile.title, iconImage=offlinefile.thumbnail,
thumbnailImage=offlinefile.thumbnail)
if offlinefile.resolution == 'original':
infolabels = decode_dict({ 'title' : offlinefile.title})
else:
infolabels = decode_dict({ 'title' : offlinefile.title + ' - ' + offlinefile.resolution })
listitem.setInfo('Video', infolabels)
listitem.setProperty('IsPlayable', 'true')
xbmcplugin.addDirectoryItem(self.plugin_handle, offlinefile.playbackpath, listitem,
isFolder=False, totalItems=0)
return offlinefile.playbackpath
##
# Calculate the number of accounts defined in settings
# parameters: the account type (usually plugin name)
##
def show_sport_selection(self):
"""Creates the KODI list items for the static sport selection"""
self.utils.log('Sport selection')
sports = self.constants.get_sports_list()
for sport in sports:
url = self.utils.build_url({'for': sport})
list_item = xbmcgui.ListItem(label=sports.get(sport).get('name'))
list_item = self.item_helper.set_art(
list_item=list_item,
sport=sport)
xbmcplugin.addDirectoryItem(
handle=self.plugin_handle,
url=url,
listitem=list_item,
isFolder=True)
xbmcplugin.addSortMethod(
handle=self.plugin_handle,
sortMethod=xbmcplugin.SORT_METHOD_DATE)
xbmcplugin.endOfDirectory(self.plugin_handle)
def __add_video_item(self, video, list_item, url):
"""
Adds a playable video item to Kodi
:param video: Video details
:type video: dict
:param list_item: Kodi list item
:type list_item: xbmcgui.ListItem
:param url: Video url
:type url: string
"""
if video.get('islivestream', True) is True:
xbmcplugin.addDirectoryItem(
handle=self.plugin_handle,
url=url,
listitem=list_item,
isFolder=False)
def add_item(queries, list_item, fanart='', is_folder=None, is_playable=None, total_items=0, menu_items=None,
replace_menu=False):
if menu_items is None: menu_items = []
if is_folder is None:
is_folder = False if is_playable else True
if is_playable is None:
playable = 'false' if is_folder else 'true'
else:
playable = 'true' if is_playable else 'false'
liz_url = get_plugin_url(queries)
if fanart: list_item.setProperty('fanart_image', fanart)
list_item.setInfo('video', {'title': list_item.getLabel()})
list_item.setProperty('isPlayable', playable)
list_item.addContextMenuItems(menu_items, replaceItems=replace_menu)
xbmcplugin.addDirectoryItem(int(sys.argv[1]), liz_url, list_item, isFolder=is_folder, totalItems=total_items)
def addMenuItem(caption, link, icon=None, thumbnail=None, folder=False):
"""
Add a menu item to the xbmc GUI
Parameters:
caption: the caption for the menu item
icon: the icon for the menu item, displayed if the thumbnail is not accessible
thumbail: the thumbnail for the menu item
link: the link for the menu item
folder: True if the menu item is a folder, false if it is a terminal menu item
Returns True if the item is successfully added, False otherwise
"""
listItem = xbmcgui.ListItem(unicode(caption), iconImage=icon, thumbnailImage=thumbnail)
listItem.setInfo(type="Video", infoLabels={ "Title": caption })
return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=link, listitem=listItem, isFolder=folder)
def addMenuItem(caption, link, icon=None, thumbnail=None, folder=False):
"""
Add a menu item to the xbmc GUI
Parameters:
caption: the caption for the menu item
icon: the icon for the menu item, displayed if the thumbnail is not accessible
thumbail: the thumbnail for the menu item
link: the link for the menu item
folder: True if the menu item is a folder, false if it is a terminal menu item
Returns True if the item is successfully added, False otherwise
"""
listItem = xbmcgui.ListItem(unicode(caption), iconImage=icon, thumbnailImage=thumbnail)
listItem.setInfo(type="Video", infoLabels={ "Title": caption })
return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=link, listitem=listItem, isFolder=folder)
def addMenuItem(caption, link, icon=None, thumbnail=None, folder=False):
"""
Add a menu item to the xbmc GUI
Parameters:
caption: the caption for the menu item
icon: the icon for the menu item, displayed if the thumbnail is not accessible
thumbail: the thumbnail for the menu item
link: the link for the menu item
folder: True if the menu item is a folder, false if it is a terminal menu item
Returns True if the item is successfully added, False otherwise
"""
listItem = xbmcgui.ListItem(unicode(caption), iconImage=icon, thumbnailImage=thumbnail)
listItem.setInfo(type="Video", infoLabels={ "Title": caption })
return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=str(link), listitem=listItem, isFolder=folder)
def addDir(name,url,mode,iconimage,plot='',isFolder=True):
try:
PID = iconimage.split('productionId=')[1]
except:pass
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)
ok=True
liz=xbmcgui.ListItem(name,iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": plot,'Premiered' : '2012-01-01','Episode' : '7-1' } )
menu=[]
if mode == 2:
menu.append(('[COLOR yellow]Add To Favourites[/COLOR]','XBMC.RunPlugin(%s?mode=13&url=%s&name=%s&iconimage=%s)'% (sys.argv[0],url,name,PID)))
if mode == 204:
menu.append(('[COLOR yellow]Remove Favourite[/COLOR]','XBMC.RunPlugin(%s?mode=14&url=%s&name=%s&iconimage=%s)'% (sys.argv[0],url,name,iconimage)))
liz.addContextMenuItems(items=menu, replaceItems=False)
if mode==3:
xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_DATE)
if isFolder==False:
liz.setProperty("IsPlayable","true")
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=isFolder)
return ok
def addDir(name,url,mode,iconimage,description):
u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&description="+urllib.quote_plus(description)
ok=True
name=replaceHTMLCodes(name)
name=name.strip()
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description} )
menu = []
if mode ==200 or mode ==201 or mode ==202 or mode ==203:
if not 'feeds' in url:
if not 'f4m' in url:
if 'm3u8' in url:
liz.setProperty('mimetype', 'application/x-mpegURL')
liz.setProperty('mimetype', 'video/MP2T')
liz.setProperty("IsPlayable","true")
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
else:
menu.append(('Play All Videos','XBMC.RunPlugin(%s?name=%s&mode=2001&iconimage=None&url=%s)'% (sys.argv[0],name,url)))
liz.addContextMenuItems(items=menu, replaceItems=False)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
def _users(self):
page = int(self.root.params['page'])
users = media_entries('fave.getUsers', self.root.conn, _NO_OWNER, page = page)
if page < users['pages']:
params = {'do': _DO_FAVE_USERS, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
for u in users['items']:
list_item = xbmcgui.ListItem(u'%s %s' % (u.info['last_name'], u.info['first_name']))
#p_key = 'photo_%d' % (max(map(lambda x: int(x.split('_')[1]), filter(lambda x: x.startswith('photo_'), m.info.keys()))),)
#list_item.setArt({'thumb': m.info[p_key], 'icon': m.info[p_key]})
params = {'do': _DO_HOME, 'oid': u.id}
url = self.root.url(**params)
xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True)
if page < users['pages']:
params = {'do': _DO_FAVE_USERS, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
xbmcplugin.endOfDirectory(_addon_id)
def _groups(self):
page = int(self.root.params['page'])
links = media_entries('fave.getLinks', self.root.conn, _NO_OWNER, page = page)
if page < links['pages']:
params = {'do': _DO_FAVE_GROUPS, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
for l in links['items']:
l_id = l.info['id'].split('_')
if l_id[0] == '2':
list_item = xbmcgui.ListItem(l.info['title'])
p_key = 'photo_%d' % (max(map(lambda x: int(x.split('_')[1]), filter(lambda x: x.startswith('photo_'), l.info.keys()))),)
list_item.setArt({'thumb': l.info[p_key], 'icon': l.info[p_key]})
params = {'do': _DO_HOME, 'oid': -int(l_id[-1])}
url = self.root.url(**params)
xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True)
if page < links['pages']:
params = {'do': _DO_FAVE_GROUPS, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
xbmcplugin.endOfDirectory(_addon_id)
def _photo_albums(self):
page = int(self.root.params['page'])
oid = self.root.params['oid']
kwargs = {'page': page, 'need_covers': 1, 'need_system': 1}
albums = media_entries('photos.getAlbums', self.root.conn, oid, **kwargs)
if page < albums['pages']:
params = {'do': _DO_PHOTO_ALBUMS,'oid': oid,'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
for a in albums['items']:
list_item = xbmcgui.ListItem(a.info['title'])
list_item.setInfo('pictures', {'title': a.info['title']})
list_item.setArt({'thumb': a.info['thumb_src'], 'icon': a.info['thumb_src']})
params = {'do': _DO_PHOTO, 'oid': oid, 'album': a.id, 'page': 1}
url = self.root.url(**params)
xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True)
if page < albums['pages']:
params = {'do': _DO_PHOTO_ALBUMS,'oid': oid,'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
xbmcplugin.endOfDirectory(_addon_id)
switch_view()
def _main_video_search(self):
page = int(self.root.params['page'])
self.root.add_folder(self.root.gui._string(400516), {'do': _DO_VIDEO_SEARCH, 'q':'none', 'page': 1})
history = get_search_history(_FILE_VIDEO_SEARCH_HISTORY)
count = len(history)
pages = int(ceil(count / float(_SETTINGS_PAGE_ITEMS)))
if page < pages:
params = {'do': _DO_MAIN_VIDEO_SEARCH, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
h_start = _SETTINGS_PAGE_ITEMS * (page -1)
h_end = h_start + _SETTINGS_PAGE_ITEMS
history = history[h_start:h_end]
for h in history:
query_hex = binascii.hexlify(pickle.dumps(h, -1))
list_item = xbmcgui.ListItem(h)
params = {'do': _DO_VIDEO_SEARCH, 'q': query_hex, 'page': 1}
url = self.root.url(**params)
xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True)
if page < pages:
params = {'do': _DO_MAIN_VIDEO_SEARCH, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
xbmcplugin.endOfDirectory(_addon_id)
def _video_albums(self):
page = int(self.root.params['page'])
oid = self.root.params['oid']
kwargs = {
'page': page,
'extended': 1
}
albums = media_entries('video.getAlbums', self.root.conn, oid, **kwargs)
if page < albums['pages']:
params = {'do': _DO_VIDEO_ALBUMS,'oid': oid,'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
for a in albums['items']:
list_item = xbmcgui.ListItem(a.info['title'])
list_item.setInfo('video', {'title': a.info['title']})
if 'photo_320' in a.info.keys():
list_item.setArt({'thumb': a.info['photo_160'], 'icon': a.info['photo_160'], 'fanart': a.info['photo_320']})
params = {'do': _DO_VIDEO, 'oid': oid, 'album': a.id, 'page': 1}
url = self.root.url(**params)
xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True)
if page < albums['pages']:
params = {'do': _DO_VIDEO_ALBUMS,'oid': oid,'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
xbmcplugin.endOfDirectory(_addon_id)
def _members(self):
oid = self.root.params['oid']
page = int(self.root.params['page'])
group = Group(oid, self.root.conn)
members = group.members(page = page)
if page < members['pages']:
params = {'do': _DO_MEMBERS, 'oid': oid, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
for m in members['items']:
list_item = xbmcgui.ListItem(u'%s %s' % (m.info['last_name'], m.info['first_name']))
p_key = 'photo_%d' % (max(map(lambda x: int(x.split('_')[1]), filter(lambda x: x.startswith('photo_'), m.info.keys()))),)
list_item.setArt({'thumb': m.info[p_key], 'icon': m.info[p_key]})
params = {'do': _DO_HOME, 'oid': m.id}
url = self.root.url(**params)
xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True)
if page < members['pages']:
params = {'do': _DO_MEMBERS, 'oid': oid, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
xbmcplugin.endOfDirectory(_addon_id)
def __create_user_group_search_page_(self, do_current, do_target, h_file):
page = int(self.root.params['page'])
self.root.add_folder(self.root.gui._string(400516), {'do': do_target, 'q':'none', 'page': 1})
history = get_search_history(h_file)
count = len(history)
pages = int(ceil(count / float(_SETTINGS_PAGE_ITEMS)))
if page < pages:
params = {'do': do_current, 'page': page + 1}
self.root.add_folder(self._string(400602), params)
h_start = _SETTINGS_PAGE_ITEMS * (page -1)
h_end = h_start + _SETTINGS_PAGE_ITEMS
history = history[h_start:h_end]
for h in history:
query_hex = binascii.hexlify(pickle.dumps(h, -1))
list_item = xbmcgui.ListItem(h)
params = {'do': do_target, 'q': query_hex, 'page': 1}
url = self.root.url(**params)
xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True)
if page < pages:
params = {'do': do_current, 'page': page + 1}
self.root.add_folder(self.root.gui._string(400602), params)
xbmcplugin.endOfDirectory(_addon_id)
def show_page(obj):
for talk in obj.get_talks():
url = build_url({'mode': 'play', 'folder_name': talk.url})
li = xbmcgui.ListItem("%s - %s [COLOR=lime][%s][/COLOR][COLOR=cyan] Posted: %s[/COLOR]" % (talk.title, talk.speaker, talk.time, talk.posted))
li.setArt({'thumb': talk.thumb, 'icon': talk.thumb, 'fanart': talk.thumb})
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
if obj.next_page:
url = build_url({'mode': 'page', 'folder_name': obj.next_page})
li = xbmcgui.ListItem("[COLOR=yellow]Next Page %s[/COLOR]" % obj.page_number(obj.next_page))
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
if obj.last_page:
url = build_url({'mode': 'page', 'folder_name': obj.last_page})
li = xbmcgui.ListItem("[COLOR=yellow]Last Page %s[/COLOR]" % obj.page_number(obj.last_page))
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
def addMenuItem(caption, link, icon=None, thumbnail=None, folder=False, fanart=None):
"""
Add a menu item to the xbmc GUI
Parameters:
caption: the caption for the menu item
icon: the icon for the menu item, displayed if the thumbnail is not accessible
thumbail: the thumbnail for the menu item
link: the link for the menu item
folder: True if the menu item is a folder, false if it is a terminal menu item
Returns True if the item is successfully added, False otherwise
"""
#listItem = xbmcgui.ListItem(unicode(caption), iconImage=icon, thumbnailImage=thumbnail)
listItem = xbmcgui.ListItem(str(caption), iconImage=icon, thumbnailImage=thumbnail)
listItem.setInfo(type="Game", infoLabels={ "Title": caption })
listItem.setProperty('fanart_image', fanart)
return xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=link, listitem=listItem, isFolder=folder)
def addMenuItem(self, name, iconImage=None, folder=True, menu=True, **kwargs):
"""Add one submenu item to the list. [internal]"""
if not iconImage:
iconImage = 'DefaultAddonsSearch.png'
# general menu item
# liz = xbmcgui.ListItem(title, iconImage="DefaultFolder.png", thumbnailImage=iconImage)
# liz.setInfo(type="Video", infoLabels={"Title": title})
url = self.buildPluginUrl(name=name, **kwargs)
xbmc.log('SEARCH: create menu item %s, query:"%s", url:"%s"' % (name, kwargs.get('query'), url))
li = xbmcgui.ListItem(kwargs.get('title', ''), iconImage="DefaultFolder.png", thumbnailImage=iconImage)
li.addContextMenuItems([
(_('Remove'), 'RunPlugin(%s)' % (url + '&action=remove')),
(_('Rename'), 'RunPlugin(%s)' % (url + '&action=rename')),
(_('Clean'), 'RunPlugin(%s)' % (url + '&action=clean')),
])
xbmcplugin.addDirectoryItem(handle=self._addonHandle, url=url, listitem=li, isFolder=folder)
def append_subtitle(subname, lang_name, language, params, sync=False, h_impaired=False):
"""Add the subtitle to the list of subtitles to show"""
listitem = xbmcgui.ListItem(
# Languange name to display under the lang logo (for example english)
label=lang_name,
# Subtitle name (for example 'Lost 1x01 720p')
label2=subname,
# Languange 2 letter name (for example en)
thumbnailImage=xbmc.convertLanguage(language, xbmc.ISO_639_1))
# Subtitles synced with the video
listitem.setProperty("sync", 'true' if sync else 'false')
# Hearing impaired subs
listitem.setProperty("hearing_imp", 'true' if h_impaired else 'false')
# Create the url to the plugin that will handle the subtitle download
url = "plugin://{url}/?{params}".format(
url=SCRIPT_ID, params=urllib.urlencode(params))
# Add the subtitle to the list
xbmcplugin.addDirectoryItem(
handle=HANDLE, url=url, listitem=listitem, isFolder=False)
def list_channels():
"""show channels on the kodi list."""
playlist = utility.read_list(playlists_file)
if not playlist:
ok(ADDON.getLocalizedString(11005), ADDON.getLocalizedString(11006))
return None
for channel in playlist:
url = channel['url'].encode('utf-8')
name = channel['display_name'].encode('utf-8')
action_url = build_url({'mode': 'play', 'url': url, 'name': name})
item = xbmcgui.ListItem(name, iconImage='DefaultVideo.png')
item.setInfo(type='Video', infoLabels={'Title': name})
xbmcplugin.addDirectoryItem(handle=HANDLE, url=action_url, listitem=item)
xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=False)
def router(paramstring):
params = dict(parse_qsl(paramstring[1:]))
if params:
if params['mode'] == 'play':
play_item = xbmcgui.ListItem(path=params['link'])
xbmcplugin.setResolvedUrl(__handle__, True, listitem=play_item)
else:
for stream in streams():
list_item = xbmcgui.ListItem(label=stream['name'], thumbnailImage=stream['thumb'])
list_item.setProperty('fanart_image', stream['thumb'])
list_item.setProperty('IsPlayable', 'true')
url = '{0}?mode=play&link={1}'.format(__url__, stream['link'])
xbmcplugin.addDirectoryItem(__handle__, url, list_item, isFolder=False)
xbmcplugin.endOfDirectory(__handle__)
# --------------------------------------------------------------------------------
# Main
# --------------------------------------------------------------------------------
def addDir(name, mode, sitemode, url='', thumb='', fanart='', infoLabels=False, totalItems=0, cm=False, page=1, options=''):
u = '%s?url=<%s>&mode=<%s>&sitemode=<%s>&name=<%s>&page=<%s>&opt=<%s>' % (sys.argv[0], urllib.quote_plus(url), mode, sitemode, urllib.quote_plus(name), urllib.quote_plus(str(page)), options)
if not fanart or fanart == na:
fanart = def_fanart
else:
u += '&fanart=<%s>' % urllib.quote_plus(fanart)
if not thumb:
thumb = def_fanart
else:
u += '&thumb=<%s>' % urllib.quote_plus(thumb)
item = xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=thumb)
item.setArt({'fanart': fanart,
'poster': thumb})
item.setProperty('IsPlayable', 'false')
try:
item.setProperty('TotalSeasons', str(infoLabels['TotalSeasons']))
except Exception:
pass
if infoLabels:
item.setInfo(type='Video', infoLabels=infoLabels)
if cm:
item.addContextMenuItems(cm, replaceItems=False)
xbmcplugin.addDirectoryItem(handle=pluginhandle, url=u, listitem=item, isFolder=True, totalItems=totalItems)
def addHELPDir(name, url, mode, iconimage, fanart, description, filetype, repourl, version, author, contextmenuitems=[],
contextreplace=False):
u = sys.argv[0] + "?url=" + urllib.quote_plus(url) + "&mode=" + str(mode) + "&name=" + urllib.quote_plus(
name) + "&iconimage=" + urllib.quote_plus(iconimage) + "&fanart=" + urllib.quote_plus(
fanart) + "&description=" + urllib.quote_plus(description) + "&filetype=" + urllib.quote_plus(
filetype) + "&repourl=" + urllib.quote_plus(repourl) + "&author=" + urllib.quote_plus(
author) + "&version=" + urllib.quote_plus(version)
ok = True
liz = xbmcgui.ListItem(name, iconImage=iconart, thumbnailImage=iconimage) # "DefaultFolder.png"
# if len(contextmenuitems) > 0:
liz.addContextMenuItems(contextmenuitems, replaceItems=contextreplace)
liz.setInfo(type="Video", infoLabels={"title": name, "plot": description})
liz.setProperty("fanart_image", fanart)
liz.setProperty("Addon.Description", description)
liz.setProperty("Addon.Creator", author)
liz.setProperty("Addon.Version", version)
# properties={'Addon.Description':meta["plot"]}
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=False)
return ok
def add_item(queries, list_item, fanart='', is_folder=None, is_playable=None, total_items=0, menu_items=None,
replace_menu=False):
if menu_items is None: menu_items = []
if is_folder is None:
is_folder = False if is_playable else True
if is_playable is None:
playable = 'false' if is_folder else 'true'
else:
playable = 'true' if is_playable else 'false'
liz_url = get_plugin_url(queries)
if fanart: list_item.setProperty('fanart_image', fanart)
list_item.setInfo('video', {'title': list_item.getLabel()})
list_item.setProperty('isPlayable', playable)
list_item.addContextMenuItems(menu_items, replaceItems=replace_menu)
xbmcplugin.addDirectoryItem(int(sys.argv[1]), liz_url, list_item, isFolder=is_folder, totalItems=total_items)
def _add_directory(self, context, directory_item, item_count=0):
item = xbmcgui.ListItem(label=directory_item.get_name(),
iconImage=u'DefaultFolder.png',
thumbnailImage=directory_item.get_image())
# only set fanart is enabled
if directory_item.get_fanart() and self.settings.show_fanart():
item.setProperty(u'fanart_image', directory_item.get_fanart())
if directory_item.get_context_menu() is not None:
item.addContextMenuItems(directory_item.get_context_menu(),
replaceItems=directory_item.replace_context_menu())
item.setInfo(type=u'video', infoLabels=info_labels.create_from_item(context, directory_item))
xbmcplugin.addDirectoryItem(handle=self.handle,
url=directory_item.get_uri(),
listitem=item,
isFolder=True,
totalItems=item_count)
def _add_image(self, context, image_item, item_count):
item = xbmcgui.ListItem(label=image_item.get_name(),
iconImage=u'DefaultPicture.png',
thumbnailImage=image_item.get_image())
# only set fanart is enabled
if image_item.get_fanart() and self.settings.show_fanart():
item.setProperty(u'fanart_image', image_item.get_fanart())
if image_item.get_context_menu() is not None:
item.addContextMenuItems(image_item.get_context_menu(), replaceItems=image_item.replace_context_menu())
item.setInfo(type=u'picture', infoLabels=info_labels.create_from_item(context, image_item))
xbmcplugin.addDirectoryItem(handle=self.handle,
url=image_item.get_uri(),
listitem=item,
totalItems=item_count)
def main(self):
filters = self.eyny.list_filters()
xbmcplugin.addDirectoryItem(
handle=self.addon_handle,
url=self._build_url('search'),
listitem=xbmcgui.ListItem('Search'),
isFolder=True)
for category in filters['categories']:
li = xbmcgui.ListItem(category['name'])
xbmcplugin.addDirectoryItem(
handle=self.addon_handle,
url=self._build_url('list', cid=category['cid']),
listitem=li,
isFolder=True)
for orderby in filters['mod']:
li = xbmcgui.ListItem(orderby['name'])
xbmcplugin.addDirectoryItem(
handle=self.addon_handle,
url=self._build_url('list', orderby=orderby['orderby']),
listitem=li,
isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
def _add_video_items(self, videos, current_url):
for video in videos:
li = xbmcgui.ListItem(label=video['title'])
li.setProperty('IsPlayable', 'true')
image_url = self.build_request_url(
video['image'], current_url)
li.setArt({
'fanart': image_url,
'icon': image_url,
'thumb': image_url
})
li.addStreamInfo('video', {
'width': video['quality'],
'aspect': 1.78,
'duration': video['duration']
})
li.setInfo('video', {'size': video['quality']})
li.setProperty('VideoResolution', str(video['quality']))
xbmcplugin.addDirectoryItem(
handle=self.addon_handle,
url=self._build_url('video', vid=video['vid']),
listitem=li,
isFolder=False)