Python xbmcplugin.addDirectoryItems() Examples
The following are 30
code examples of xbmcplugin.addDirectoryItems().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xbmcplugin
, or try the search function
.
Example #1
Source File: addon.py From script.module.clouddrive.common with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
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)
Example #3
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
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)
Example #4
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
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
Example #5
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 6 votes |
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)
Example #6
Source File: addon.py From script.module.clouddrive.common with GNU General Public License v3.0 | 6 votes |
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='/')
Example #7
Source File: default.py From kodi with GNU General Public License v3.0 | 6 votes |
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)
Example #8
Source File: xswift2.py From plugin.video.openmeta with GNU General Public License v3.0 | 5 votes |
def add_items(self, items): _items = [self._listitemify(item) for item in items] tuples = [item.as_tuple() for item in _items if hasattr(item, 'as_tuple')] xbmcplugin.addDirectoryItems(self.handle, tuples, len(tuples)) self.added_items.extend(_items) return _items
Example #9
Source File: koditidal.py From plugin.audio.tidal2 with GNU General Public License v3.0 | 5 votes |
def add_list_items(self, items, content=None, end=True, withNextPage=False): if content: xbmcplugin.setContent(plugin.handle, content) list_items = [] for item in items: if isinstance(item, Category): category_items = item.getListItems() for url, li, isFolder in category_items: if url and li: list_items.append(('%s/' % url if isFolder else url, li, isFolder)) elif isinstance(item, BrowsableMedia): url, li, isFolder = item.getListItem() if url and li: list_items.append(('%s/' % url if isFolder else url, li, isFolder)) if withNextPage and len(items) > 0: # Add folder for next page try: totalNumberOfItems = items[0]._totalNumberOfItems nextOffset = items[0]._offset + self._config.pageSize if nextOffset < totalNumberOfItems and len(items) >= self._config.pageSize: path = urlsplit(sys.argv[0]).path or '/' path = path.split('/')[:-1] path.append(str(nextOffset)) url = '/'.join(path) self.add_directory_item(_T(30244).format(pos1=nextOffset, pos2=min(nextOffset+self._config.pageSize, totalNumberOfItems)), plugin.url_for_path(url)) except: log('Next Page for URL %s not set' % sys.argv[0], xbmc.LOGERROR) if len(list_items) > 0: xbmcplugin.addDirectoryItems(plugin.handle, list_items) if end: xbmcplugin.endOfDirectory(plugin.handle)
Example #10
Source File: main.py From plugin.video.areena with GNU General Public License v2.0 | 5 votes |
def show_credentials_needed_menu(): listing = [] missing_credentials_list_item = xbmcgui.ListItem(label=get_translation(32038)) missing_credentials_url = '{0}'.format(_url) listing.append((missing_credentials_url, missing_credentials_list_item, True)) open_settings_list_item = xbmcgui.ListItem(label=get_translation(32039)) open_settings_url = '{0}?action=settings'.format(_url) listing.append((open_settings_url, open_settings_list_item, True)) # Add our listing to Kodi. xbmcplugin.addDirectoryItems(_handle, listing, len(listing)) # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_NONE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
Example #11
Source File: addon.py From script.module.clouddrive.common with GNU General Public License v3.0 | 5 votes |
def list_accounts(self): accounts = self.get_accounts(with_format=True) listing = [] for account_id in accounts: account = accounts[account_id] size = len(account['drives']) for drive in account['drives']: context_options = [] params = {'action':'_search', 'content_type': self._content_type, 'driveid': drive['id']} cmd = 'ActivateWindow(%d,%s?%s)' % (xbmcgui.getCurrentWindowId(), self._addon_url, urllib.urlencode(params)) context_options.append((self._common_addon.getLocalizedString(32039), cmd)) params['action'] = '_remove_account' context_options.append((self._common_addon.getLocalizedString(32006), 'RunPlugin('+self._addon_url + '?' + urllib.urlencode(params)+')')) if size > 1: params['action'] = '_remove_drive' cmd = 'RunPlugin('+self._addon_url + '?' + urllib.urlencode(params)+')' context_options.append((self._common_addon.getLocalizedString(32007), cmd)) list_item = xbmcgui.ListItem(drive['display_name']) list_item.addContextMenuItems(context_options) params = {'action':'_list_drive', 'content_type': self._content_type, 'driveid': drive['id']} url = self._addon_url + '?' + urllib.urlencode(params) listing.append((url, list_item, True)) list_item = xbmcgui.ListItem(self._common_addon.getLocalizedString(32005)) params = {'action':'_add_account', 'content_type': self._content_type} url = self._addon_url + '?' + urllib.urlencode(params) listing.append((url, list_item)) xbmcplugin.addDirectoryItems(self._addon_handle, listing, len(listing)) xbmcplugin.endOfDirectory(self._addon_handle, True)
Example #12
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
def list_videos(category,offset=0): #request=urllib2.Request('http://www.douyu.com'+category,headers=headers) #f=urllib2.urlopen(request) #f=urllib2.urlopen('http://www.douyu.com'+category) #r=f.read() #rr=BeautifulSoup(r) rr=BeautifulSoup(requests.get('http://www.douyu.com'+category,headers=headers).text) videol=rr.findAll('a',{'class':'play-list-link'},limit=offset+PAGE_LIMIT+1) listing=[] #with open('rooml.dat','w') as f: # f.writelines([str(x) for x in videol]) if offset+PAGE_LIMIT<len(videol): videol=videol[offset:offset+PAGE_LIMIT] nextpageflag=True else: videol=videol[offset:] nextpageflag=False for x in videol: roomid=x['href'][1:] img=x.img['data-original'] title=x['title'] nickname=x.find('span',{'class':'dy-name ellipsis fl'}).text view=x.find('span',{'class':'dy-num fr'}).text liveinfo=u'{0}:{1}:{2}'.format(nickname,title,view) list_item=xbmcgui.ListItem(label=liveinfo,thumbnailImage=img) #list_item.setProperty('fanart_image',img) url='{0}?action=play&video={1}'.format(_url,roomid) is_folder=False listing.append((url,list_item,is_folder)) if nextpageflag==True: list_item=xbmcgui.ListItem(label=NEXT_PAGE) url='{0}?action=listing&category={1}&offset={2}'.format(_url,category,offset+PAGE_LIMIT) 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)
Example #13
Source File: plugin_content.py From script.skin.helper.service with GNU General Public License v2.0 | 5 votes |
def getcastmedia(self): '''helper to display get all media for a specific actor''' name = self.params.get("name") if name: all_items = self.mutils.kodidb.castmedia(name) all_items = self.mutils.process_method_on_list(self.mutils.kodidb.prepare_listitem, all_items) all_items = self.mutils.process_method_on_list(self.mutils.kodidb.create_listitem, all_items) xbmcplugin.addDirectoryItems(int(sys.argv[1]), all_items, len(all_items)) xbmcplugin.endOfDirectory(handle=int(sys.argv[1]))
Example #14
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
def list_categories(offset): #f=urllib2.urlopen('http://www.douyutv.com/directory') #rr=BeautifulSoup(f.read()) rr=BeautifulSoup(requests.get('http://www.douyutv.com/directory',headers=headers).text) catel=rr.findAll('a',{'class':'thumb'},limit=offset+PAGE_LIMIT+1) rrr=[(x['href'], x.p.text,x.img['data-original']) for x in catel] offset=int(offset) if offset+PAGE_LIMIT<len(rrr): rrr=rrr[offset:offset+PAGE_LIMIT] nextpageflag=True else: rrr=rrr[offset:] nextpageflag=False listing=[] for classname,textinfo,img in rrr: list_item=xbmcgui.ListItem(label=textinfo,thumbnailImage=img) #list_item.setProperty('fanart_image',img) url=u'{0}?action=listing&category={1}&offset=0'.format(_url,classname) is_folder=True listing.append((url,list_item,is_folder)) if nextpageflag==True: list_item=xbmcgui.ListItem(label=NEXT_PAGE) url=u'{0}?offset={1}'.format(_url,str(offset+PAGE_LIMIT)) 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)
Example #15
Source File: main.py From plugin.video.areena with GNU General Public License v2.0 | 5 votes |
def list_categories(base_category): """ Create the list of the categories in the Kodi interface. :param base_category: the parent category to require from all categories :return: None """ listing = list_sub_categories(base_category) # 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)
Example #16
Source File: main.py From plugin.video.areena with GNU General Public License v2.0 | 5 votes |
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')
Example #17
Source File: main.py From plugin.video.areena with GNU General Public License v2.0 | 5 votes |
def show_menu(): if get_app_id() == '' or get_app_key() == '' or get_secret_key() == '': return show_credentials_needed_menu() listing = [] tv_list_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format( get_color('menuItemColor'), get_translation(32031))) tv_url = '{0}?action=categories&base=5-130'.format(_url) listing.append((tv_url, tv_list_item, True)) live_tv_list_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format( get_color('menuItemColor'), get_translation(32067))) live_tv_url = '{0}?action=live'.format(_url) listing.append((live_tv_url, live_tv_list_item, True)) radio_list_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format( get_color('menuItemColor'), get_translation(32032))) radio_url = '{0}?action=categories&base=5-200'.format(_url) listing.append((radio_url, radio_list_item, True)) search_list_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format( get_color('menuItemColor'), get_translation(32007))) search_url = '{0}?action=search'.format(_url) listing.append((search_url, search_list_item, True)) favourites_list_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format( get_color('menuItemColor'), get_translation(32025))) favourites_url = '{0}?action=favourites'.format(_url) listing.append((favourites_url, favourites_list_item, True)) open_settings_list_item = xbmcgui.ListItem(label='[COLOR {0}]{1}[/COLOR]'.format( get_color('menuItemColor'), get_translation(32040))) open_settings_url = '{0}?action=settings'.format(_url) listing.append((open_settings_url, open_settings_list_item, True)) # Add our listing to Kodi. xbmcplugin.addDirectoryItems(_handle, listing, len(listing)) # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(_handle, xbmcplugin.SORT_METHOD_NONE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(_handle)
Example #18
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
def list_sections(section): if section == "#": return html = get(_meijumao+section) soup = BeautifulSoup(html,"html5lib") will_page = soup.find("ul",attrs={"id":"will_page"}) if will_page: pass listing = [] for section in soup.find_all("article"): list_item = xbmcgui.ListItem(label=section.div.a.img.get("alt"),thumbnailImage=section.div.a.img.get("src")) list_item.setProperty('fanart_image', section.div.a.img.get("src")) url = '{0}?action=list_series&series={1}&seriesname={2}&fanart_image={3}'.format(_url, section.div.a.get("href"),section.div.a.img.get("alt").encode("utf-8"),section.div.a.img.get("src")) is_folder=True listing.append((url, list_item, is_folder)) #pagination will_page = soup.find("ul",attrs={"id":"will_page"}).find_all("li") if len(will_page) > 0: # print will_page[0].get("class"),will_page[0].find("a").get("href") list_item = xbmcgui.ListItem(label="上一页") url='{0}?action=list_sections§ion={1}'.format(_url, will_page[0].find("a").get("href")) is_folder=True listing.append((url, list_item, is_folder)) list_item = xbmcgui.ListItem(label="下一页") url='{0}?action=list_sections§ion={1}'.format(_url, will_page[-1].find("a").get("href")) is_folder=True listing.append((url, list_item, is_folder)) xbmcplugin.addDirectoryItems(_handle,listing,len(listing)) xbmcplugin.endOfDirectory(_handle)
Example #19
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 5 votes |
def index(): listing = [] for i in __index__: list_item = xbmcgui.ListItem(label=i[1]) url='{0}?action=index_router&article={1}'.format(_url,i[0]) is_folder=True listing.append((url, list_item, is_folder)) xbmcplugin.addDirectoryItems(_handle,listing,len(listing)) xbmcplugin.endOfDirectory(_handle) # get articles
Example #20
Source File: default.py From kodi with GNU General Public License v3.0 | 5 votes |
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()
Example #21
Source File: default.py From kodi with GNU General Public License v3.0 | 5 votes |
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)
Example #22
Source File: default.py From kodi with GNU General Public License v3.0 | 5 votes |
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)
Example #23
Source File: default.py From kodi with GNU General Public License v3.0 | 5 votes |
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)
Example #24
Source File: default.py From kodi with GNU General Public License v3.0 | 5 votes |
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)
Example #25
Source File: default.py From kodi with GNU General Public License v3.0 | 5 votes |
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
Example #26
Source File: directory_utils.py From plugin.video.netflix with MIT License | 5 votes |
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)
Example #27
Source File: directory_utils.py From plugin.video.netflix with MIT License | 5 votes |
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
Example #28
Source File: addon.py From xbmc-addons-chinese with GNU General Public License v2.0 | 4 votes |
def list_categories(): f = urllib2.urlopen('http://api.m.panda.tv/ajax_get_all_subcate?__version=1.0.5.1098&__plat=iOS') obj = json.loads(f.read()) listing=[] list_item = xbmcgui.ListItem(label='全部直播') # list_item.setProperty('fanart_image', game['img']) url='{0}?action=all'.format(_url) listing.append((url, list_item, True)) for game in obj['data']: list_item = xbmcgui.ListItem(label=game['cname'], thumbnailImage=game['img']) list_item.setProperty('fanart_image', game['img']) url='{0}?action=room_list&game_id={1}'.format(_url, game['ename']) 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) # def all_list(): # html = urllib2.urlopen('https://www.panda.tv/all').read() # # room_ids = re.findall(r'<a href="/\d+" class="video-list-item-wrap" data-id="(\d+)">', html) # room_infos = RE_ROOM_INFOS.findall(html, re.MULTILINE) # room_imgs = RE_ROOM_IMG.findall(html) # # listing=[] # for i, room_id in enumerate(room_ids): # room_name, author, view_count = room_infos[i] # img = room_imgs[i] # title = TITLE_PATTERN.format(topic=room_name, author=author, view_count=view_count) # list_item = xbmcgui.ListItem(label=title, thumbnailImage=img) # list_item.setProperty('fanart_image', 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.endOfDirectory(_handle)
Example #29
Source File: main.py From script.skin.helper.widgets with GNU General Public License v2.0 | 4 votes |
def mainlisting(self): '''main listing''' all_items = [] xbmcplugin.setContent(ADDON_HANDLE, "files") # movie node if xbmc.getCondVisibility("Library.HasContent(movies)"): all_items.append((xbmc.getLocalizedString(342), "movieslisting", "DefaultMovies.png")) # tvshows and episodes nodes if xbmc.getCondVisibility("Library.HasContent(tvshows)"): all_items.append((xbmc.getLocalizedString(20343), "tvshowslisting", "DefaultTvShows.png")) all_items.append((xbmc.getLocalizedString(20360), "episodeslisting", "DefaultTvShows.png")) # pvr node if xbmc.getCondVisibility("Pvr.HasTVChannels"): all_items.append((self.addon.getLocalizedString(32054), "pvrlisting", "DefaultAddonPVRClient.png")) # music nodes if xbmc.getCondVisibility("Library.HasContent(music)"): all_items.append((xbmc.getLocalizedString(132), "albumslisting", "DefaultAlbumCover.png")) all_items.append((xbmc.getLocalizedString(134), "songslisting", "DefaultMusicSongs.png")) all_items.append((xbmc.getLocalizedString(133), "artistslisting", "DefaultArtist.png")) # musicvideo node if xbmc.getCondVisibility("Library.HasContent(musicvideos)"): all_items.append((xbmc.getLocalizedString(20389), "musicvideoslisting", "DefaultAddonAlbumInfo.png")) # media node if xbmc.getCondVisibility( "Library.HasContent(movies) | Library.HasContent(tvshows) | Library.HasContent(music)"): all_items.append((self.addon.getLocalizedString(32057), "medialisting", "DefaultAddonAlbumInfo.png")) # favourites node all_items.append((xbmc.getLocalizedString(10134), "favouriteslisting", "DefaultAddonAlbumInfo.png")) # process the listitems and display listing all_items = self.metadatautils.process_method_on_list(create_main_entry, all_items) all_items = self.metadatautils.process_method_on_list(self.metadatautils.kodidb.prepare_listitem, all_items) all_items = self.metadatautils.process_method_on_list(self.metadatautils.kodidb.create_listitem, all_items) xbmcplugin.addDirectoryItems(ADDON_HANDLE, all_items, len(all_items)) xbmcplugin.endOfDirectory(handle=ADDON_HANDLE)
Example #30
Source File: plugin_content.py From plugin.audio.spotify with GNU General Public License v3.0 | 4 votes |
def add_track_listitems(self, tracks, append_artist_to_label=False): list_items = [] for count, track in enumerate(tracks): if append_artist_to_label: label = "%s - %s" % (track["artist"], track['name']) else: label = track['name'] duration = track["duration_ms"] / 1000 if KODI_VERSION > 17: li = xbmcgui.ListItem(label, offscreen=True) else: li = xbmcgui.ListItem(label) if self.local_playback and self.connect_id: # local playback by using proxy on a remote machine url = "http://%s:%s/track/%s/%s" % (self.connect_id, PROXY_PORT, track['id'], duration) li.setProperty("isPlayable", "true") elif self.local_playback: # local playback by using proxy on this machine url = "http://localhost:%s/track/%s/%s" % (PROXY_PORT, track['id'], duration) li.setProperty("isPlayable", "true") else: # connect controlled playback li.setProperty("isPlayable", "false") if self.playlistid: url = "plugin://plugin.audio.spotify/?action=connect_playback&trackid=%s&playlistid=%s&ownerid=%s&offset=%s" % ( track['id'], self.playlistid, self.ownerid, count) elif self.albumid: url = "plugin://plugin.audio.spotify/?action=connect_playback&trackid=%s&albumid=%s&offset=%s" % (track[ 'id'], self.albumid, count) else: url = "plugin://plugin.audio.spotify/?action=connect_playback&trackid=%s" % (track['id']) if self.append_artist_to_title: title = label else: title = track['name'] li.setInfo('music', { "title": title, "genre": track["genre"], "year": track["year"], "tracknumber": track["track_number"], "album": track['album']["name"], "artist": track["artist"], "rating": track["rating"], "duration": duration }) li.setArt({"thumb": track['thumb']}) li.setProperty("spotifytrackid", track['id']) li.setContentLookup(False) li.addContextMenuItems(track["contextitems"], True) li.setProperty('do_not_analyze', 'true') li.setMimeType("audio/wave") list_items.append((url, li, False)) xbmcplugin.addDirectoryItems(self.addon_handle, list_items, totalItems=len(list_items))