本文整理汇总了Python中xbmcplugin.addDirectoryItems方法的典型用法代码示例。如果您正苦于以下问题:Python xbmcplugin.addDirectoryItems方法的具体用法?Python xbmcplugin.addDirectoryItems怎么用?Python xbmcplugin.addDirectoryItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xbmcplugin
的用法示例。
在下文中一共展示了xbmcplugin.addDirectoryItems方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def show(self, link, image, name):
response = common.fetchPage({"link": link})
cid = link.split(self.url + "/")[-1].split("-")[0]
playlist = self.getPlaylist(response['content'])
if playlist:
description = self.strip(response['content'].split("<!--dle_image_end-->")[1].split("<div")[0])
currname = ''
duration = ''
#description = common.parseDOM(response['content'], "meta", attrs={"name": "description"}, ret = "content")[0]
if (self.use_epg == "true"):
currname, duration, listItems = self.getEPG(cid = cid, cname=name, image=image)
uri = sys.argv[0] + '?mode=play&url=%s&url2=%s' % (urllib.quote_plus(playlist), link)
item = xbmcgui.ListItem("[COLOR=FF7B68EE]%s[/COLOR]" % self.language(1004), iconImage=image, thumbnailImage=image)
item.setInfo(type='Video', infoLabels={'title': currname if currname != '' else name, 'plot': description, 'duration': duration})
item.setProperty('IsPlayable', 'true')
xbmcplugin.addDirectoryItem(self.handle, uri, item, False)
if (self.use_epg == "true"):
xbmcplugin.addDirectoryItems(self.handle, listItems)
xbmcplugin.setContent(self.handle, 'files')
xbmcplugin.endOfDirectory(self.handle, True)
示例2: room_list
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def room_list(game_id):
if game_id == 'ALL':
apiurl = 'http://api.m.panda.tv/ajax_live_lists'
params = 'pageno=1&pagenum=100&status=2&order=person_num&sproom=1&__version=2.0.1.1481&__plat=android&banner=1'
else:
apiurl = "http://api.m.panda.tv/ajax_get_live_list_by_cate"
params = "__plat=iOS&__version=1.0.5.1098&cate={ename}&order=person_num&pageno=1&pagenum=100&status=2".format(ename=game_id)
returndata = post(apiurl, params);
obj = json.loads(returndata)
listing=[]
for room in obj['data']['items']:
title = TITLE_PATTERN.format(topic=room['name'].encode('utf-8'), author=room['userinfo']['nickName'].encode('utf-8'), view_count=room['person_num'].encode('utf-8'))
list_item = xbmcgui.ListItem(label=title, thumbnailImage=room['pictures']['img'])
list_item.setProperty('fanart_image', room['pictures']['img'])
url='{0}?action=play&room_id={1}'.format(_url, room['id'])
is_folder=False
listing.append((url, list_item, is_folder))
xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
#xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
示例3: list_categories
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def list_categories(article):
html = get(_meijumao + article )
soup = BeautifulSoup(html,"html5lib")
listing = []
for urls in soup.find_all("a",attrs={"data-remote":"true"}):
list_item = xbmcgui.ListItem(label=urls.div.get_text())
url='{0}?action=list_sections§ion={1}'.format(_url, urls.get("href").replace(_meijumao,""))
is_folder=True
listing.append((url, list_item, is_folder))
xbmcplugin.addDirectoryItems(_handle,listing,len(listing))
#xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
# get sections
示例4: list_categories
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def list_categories():
f = urllib2.urlopen('http://www.zhanqi.tv/api/static/game.lists/100-1.json?rand={ts}'.format(ts=time.time()))
obj = json.loads(f.read())
listing=[]
for game in obj['data']['games']:
list_item = xbmcgui.ListItem(label=game['name'], thumbnailImage=game['bpic'])
list_item.setProperty('fanart_image', game['bpic'])
url='{0}?action=room_list&game_id={1}'.format(_url, game['id'])
#xbmc.log(url, 1)
is_folder=True
listing.append((url, list_item, is_folder))
xbmcplugin.addDirectoryItems(_handle,listing,len(listing))
#xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
示例5: room_list
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def room_list(game_id):
f = urllib2.urlopen('http://www.zhanqi.tv/api/static/game.lives/{game_id}/100-1.json?rand={ts}'.format(game_id=game_id, ts=time.time()))
obj = json.loads(f.read())
listing=[]
for room in obj['data']['rooms']:
list_item = xbmcgui.ListItem(label=room['title'], thumbnailImage=room['bpic'])
list_item.setProperty('fanart_image', room['bpic'])
url='{0}?action=play&room_id={1}'.format(_url, room['id'])
is_folder=False
listing.append((url, list_item, is_folder))
xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
#xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
# Finish creating a virtual folder.
xbmcplugin.endOfDirectory(_handle)
示例6: _list_drive
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def _list_drive(self, driveid):
drive_folders = self.get_custom_drive_folders(driveid)
if self.cancel_operation():
return
if drive_folders:
listing = []
url = self._addon_url + '?' + urllib.urlencode({'action':'_list_folder', 'path': '/', 'content_type': self._content_type, 'driveid': driveid})
listing.append((url, xbmcgui.ListItem('[B]%s[/B]' % self.get_my_files_menu_name()), True))
for folder in drive_folders:
params = {'action':'_list_folder', 'path': folder['path'], 'content_type': self._content_type, 'driveid': driveid}
if 'params' in folder:
params.update(folder['params'])
url = self._addon_url + '?' + urllib.urlencode(params)
list_item = xbmcgui.ListItem(Utils.unicode(folder['name']))
if 'context_options' in folder:
list_item.addContextMenuItems(folder['context_options'])
listing.append((url, list_item, True))
if self._content_type == 'video' or self._content_type == 'audio':
url = self._addon_url + '?' + urllib.urlencode({'action':'_list_exports', 'content_type': self._content_type, 'driveid': driveid})
listing.append((url, xbmcgui.ListItem(self._common_addon.getLocalizedString(32000)), True))
xbmcplugin.addDirectoryItems(self._addon_handle, listing, len(listing))
xbmcplugin.endOfDirectory(self._addon_handle, True)
else:
self._list_folder(driveid, path='/')
示例7: _list_exports
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def _list_exports(self, driveid):
self._export_manager = ExportManager(self._account_manager._addon_data_path)
exports = self._export_manager.load()
listing = []
for exportid in exports:
export = exports[exportid]
if export['driveid'] == driveid and export['content_type'] == self._content_type:
item_name = Utils.unicode(export['name'])
params = {'action':'_open_export', 'content_type': self._content_type, 'driveid': driveid, 'item_driveid': export['item_driveid'], 'item_id': export['id'], 'name': urllib.quote(Utils.str(item_name))}
url = self._addon_url + '?' + urllib.urlencode(params)
list_item = xbmcgui.ListItem(item_name)
context_options = []
params['action'] = '_run_export'
context_options.append((KodiUtils.localize(21479), 'RunPlugin('+self._addon_url + '?' + urllib.urlencode(params)+')'))
params['action'] = '_remove_export'
context_options.append((KodiUtils.localize(1210), 'RunPlugin('+self._addon_url + '?' + urllib.urlencode(params)+')'))
list_item.addContextMenuItems(context_options)
listing.append((url, list_item, True))
xbmcplugin.addDirectoryItems(self._addon_handle, listing, len(listing))
xbmcplugin.endOfDirectory(self._addon_handle, True)
示例8: convert_list_to_dir_items
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def convert_list_to_dir_items(list_data):
"""Convert a generic list (of dict) items into a list of directory tuple items for xbmcplugin.addDirectoryItems"""
directory_items = []
for dict_item in list_data:
directory_items.append((dict_item['url'], _convert_dict_to_listitem(dict_item), dict_item['is_folder']))
return directory_items
示例9: finalize_directory
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def finalize_directory(items, content_type=g.CONTENT_FOLDER, sort_type='sort_nothing', title=None):
"""Finalize a directory listing. Add items, set available sort methods and content type"""
if title:
xbmcplugin.setPluginCategory(g.PLUGIN_HANDLE, title)
xbmcplugin.setContent(g.PLUGIN_HANDLE, content_type)
add_sort_methods(sort_type)
xbmcplugin.addDirectoryItems(g.PLUGIN_HANDLE, items)
示例10: getEPG
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def getEPG(self, cid = None, cname = None, image = ''):
currname = ''
duration = 0
listItems = []
try:
if cname:
if cid:
epgbody = self.epg[cid]['epg']
currname, duration, listItems = self.addEPGItems(epgbody, image)
elif cid:
epgbody = self.epg[cid]['epg']
currname, duration, listItems = self.addEPGItems(epgbody, image)
xbmcplugin.addDirectoryItems(self.handle, listItems)
else:
for channelid in self.epg:
channelbody = self.epg[channelid]
uri = sys.argv[0] + '?mode=epg&cid=%s&image=%s' % (channelid, channelbody['image_url'])
item = xbmcgui.ListItem("%s" % channelbody['title'], iconImage=channelbody['image_url'], thumbnailImage=channelbody['image_url'])
item.setInfo(type='Video', infoLabels={'title': channelbody['title']})
commands = []
uricmd = sys.argv[0] + '?mode=show&url=%s&name=%s&image=%s' % (self.url + "/" + channelid + "-" + channelbody['alt_name'] + ".html", channelbody['title'], channelbody['image_url'])
commands.append(('[COLOR=FF00FF00]' + self.language(1006) + '[/COLOR]', "Container.Update(%s)" % (uricmd), ))
item.addContextMenuItems(commands)
xbmcplugin.addDirectoryItem(self.handle, uri, item, True)
xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_TITLE)
except:
pass
if cname == None:
xbmcplugin.setContent(self.handle, 'files')
xbmcplugin.endOfDirectory(self.handle, True)
return currname, duration, listItems
示例11: show_playlist
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def show_playlist(self, owner_id, playlist_id, **kwargs):
playlist = Playlist(owner_id, playlist_id)
track_list = get_track_list(album_id=playlist.id, tracks=playlist.playlist['tracks'])
xbmcplugin.addDirectoryItems(self.handle, track_list, len(track_list))
xbmcplugin.setContent(self.handle, 'songs')
xbmcplugin.endOfDirectory(self.handle)
示例12: show_album
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def show_album(self, album_id, **kwargs):
album = Album(album_id)
info = {'year': album.year, 'genre': album.genre}
track_list = get_track_list(album_id=album_id, tracks=album.volumes[0], info=info)
xbmcplugin.addDirectoryItems(self.handle, track_list, len(track_list))
xbmcplugin.setContent(self.handle, 'songs')
xbmcplugin.endOfDirectory(self.handle)
示例13: show_artist
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def show_artist(self, artist_id, **kwargs):
artist = Artist(artist_id)
album_list = get_album_list(artist.albums)
xbmcplugin.addDirectoryItems(self.handle, album_list, len(album_list))
xbmcplugin.setContent(self.handle, 'albums')
xbmcplugin.endOfDirectory(self.handle)
示例14: my_music
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def my_music(self, filter_name=None, **kwargs):
if not filter_name:
routers = [
{'name': '[COLOR=FF00FFFF]Треки[/COLOR]', 'uri': '?mode=my&filter_name=tracks'},
{'name': '[COLOR=FF00FFFF]Альбомы[/COLOR]', 'uri': '?mode=my&filter_name=albums'},
{'name': '[COLOR=FF00FFFF]Плейлисты[/COLOR]', 'uri': '?mode=my&filter_name=playlists'},
{'name': '[COLOR=FF00FFFF]Исполнители[/COLOR]', 'uri': '?mode=my&filter_name=artists'},
]
return self.draw_menu(routers)
library = self.api.library(self.settings['account']['owner'], filter_name)
if filter_name == 'tracks':
items_list = get_track_list(album_id=library['owner']['uid'], tracks=library['tracks'])
content_type = 'songs'
elif filter_name == 'albums':
items_list = get_album_list(library['albums'])
content_type = 'albums'
elif filter_name == 'playlists':
items_list = get_playlist_list(library['bookmarks'])
content_type = 'albums'
elif filter_name == 'artists':
items_list = get_artist_list(library['artists'])
content_type = 'artists'
else:
items_list = []
content_type = ''
xbmcplugin.addDirectoryItems(self.handle, items_list, len(items_list))
xbmcplugin.setContent(self.handle, content_type)
xbmcplugin.endOfDirectory(self.handle)
示例15: search
# 需要导入模块: import xbmcplugin [as 别名]
# 或者: from xbmcplugin import addDirectoryItems [as 别名]
def search(self, **kwargs):
keyboard = xbmc.Keyboard()
keyboard.doModal()
if keyboard.isConfirmed():
search_response = self.api.search(keyboard.getText(), search_type='albums')
album_list = get_album_list(search_response['albums']['items'])
xbmcplugin.addDirectoryItems(self.handle, album_list, len(album_list))
xbmcplugin.setContent(self.handle, 'albums')
xbmcplugin.endOfDirectory(self.handle)
else:
self.main()