def addCat(self, name, url, icon, mode): if self.lograwdata: self.log("Adding Cat: " + str(name) + "," + str(url) + "," + str(icon) + " MODE: " + str(mode)) category_url = '%s?%s' % (self.base_url, urlencode({ 'url': url, 'mode': mode, 'name': name, })) liz = xbmcgui.ListItem(name) liz.setArt({'fanart': self.get_resource("fanart.jpg"), 'thumb': icon, 'icon': icon}) liz.setInfo(type="Video", infoLabels={"Title": name}) liz.setProperty('isPlayable', "false") xbmcplugin.addDirectoryItem(handle=self.handle, url=category_url, listitem=liz, isFolder=True)
def root(): xbmcplugin.addDirectoryItem( plugin.handle, plugin.url_for(channel_list, url="http://chlist.sopplus.tv/v1/channels"), xbmcgui.ListItem("sopplus.tv - V1"), isFolder=True) xbmcplugin.addDirectoryItem( plugin.handle, plugin.url_for(channel_list, url="http://chlist.sopplus.tv/v2/channels"), xbmcgui.ListItem("sopplus.tv - V2"), isFolder=True) xbmcplugin.endOfDirectory(plugin.handle)
def addLink(self, name, uri=(''), infoList={}, infoArt={}, infoVideo={}, infoAudio={}, infoType='video', listitem=None, total=0): log('addLink, name = %s'%name) if listitem is None: liz = xbmcgui.ListItem(name) if infoList: liz.setInfo(type=infoType, infoLabels=infoList) else: liz.setInfo(type=infoType, infoLabels={"mediatype":infoType,"label":name,"title":name}) if infoArt: liz.setArt(infoArt) else: liz.setArt({'thumb':ICON,'fanart':FANART}) if infoVideo: liz.addStreamInfo('video', infoVideo) if infoAudio: liz.addStreamInfo('audio', infoAudio) if infoList.get('favorite',None) is not None: liz = self.addContextMenu(liz, infoList) else: liz = listitem liz.setProperty('IsPlayable','true') xbmcplugin.addDirectoryItem(ROUTER.handle, ROUTER.url_for(*uri), liz, isFolder=False, totalItems=total)
def build_categories_menu(self): """ Builds the 'Categories' menu. """ category_list = [{ 'display_name': LANGUAGE(30053), 'group_name': 'am-meisten-gesehen', 'relative_url': None, }, { 'display_name': LANGUAGE(30054), 'group_name': 'viral', 'relative_url': None, }, { 'display_name': LANGUAGE(30055), 'group_name': 'unterhaltung', 'relative_url': None, }, { 'display_name': LANGUAGE(30056), 'group_name': 'sport', 'relative_url': '/sport', }, { 'display_name': LANGUAGE(30051), 'group_name': 'news', 'relative_url': '/news', }] # The group 'Series' do not contain videos, but only links to shows, # so there is currently no need to add them to the list. They would # have the following category_list layout: # { # 'display_name': 'Series', # 'group_name': 'serien', # 'relative_url': None # } for cat_item in category_list: list_item = xbmcgui.ListItem(cat_item['display_name']) list_item.setProperty('IsPlayable', 'false') list_item.setArt({'thumb': self.icon()}) if cat_item['relative_url']: url = self.build_url(mode=20, name=cat_item['relative_url']) else: url = self.build_url(mode=20, name='/videos', group=cat_item['group_name']) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=list_item, isFolder=True)
def directory(label, path, folder=True, artwork=None, fanart=None, context=None): ''' Add directory listitem. context should be a list of tuples [(label, action)*] ''' li = dir_listitem(label, path, artwork, fanart) if context: li.addContextMenuItems(context) xbmcplugin.addDirectoryItem(PROCESS_HANDLE, path, li, folder) return li
def addUserFavDir(name, url, mode, iconimage): u = "{0}?url={1}&mode={2}".format(sys.argv[0], urllib_parse.quote_plus(url), mode) ok = True liz = xbmcgui.ListItem(name) liz.setArt({ 'thumb': iconimage, 'icon': _icon, 'poster': iconimage, 'fanart': _fanart }) liz.setInfo(type="Video", infoLabels={"Title": name}) if dmUser == "": playListInfos = "###MODE###=REMOVE###REFRESH###=TRUE###USER###={0}###THUMB###={1}###END###".format( name, iconimage) liz.addContextMenuItems([( translation(30029), 'RunPlugin(plugin://{0}/?mode=favourites&url={1})'.format( addonID, urllib_parse.quote_plus(playListInfos)), )]) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) return ok
def addDir(name, mode, game_day=None, start_inning='False', level=None, teams=None): ok = True u = sys.argv[0] + "?mode=" + str(mode) + "&name=" + urllib.quote_plus(name) if game_day is not None: u = u + "&game_day=" + urllib.quote_plus(game_day) if start_inning != 'False': u = u + "&start_inning=" + urllib.quote_plus(start_inning) if level is not None: u = u + "&level=" + urllib.quote_plus(level) if teams is not None: u = u + "&teams=" + urllib.quote_plus(teams) liz = xbmcgui.ListItem(name) liz.setArt({'icon': ICON, 'thumb': ICON, 'fanart': FANART}) liz.setInfo(type="Video", infoLabels={"Title": name}) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) xbmcplugin.setContent(int(sys.argv[1]), 'episodes') return ok
def addStream(name, url, mode, icon='', lang='',info=None): u=_plugin_url+"?url="+quote_plus(url)+"&mode="+str(mode)+"&name="+quote_plus(name)+"&lang="+quote_plus(lang)+"&einthusanRedirectUrl="+quote_plus(einthusanRedirectUrl) name,url,lang,isithd,referurl=url.split(',') if isithd=='itshd': name = name + ' [COLOR blue][I]Ultra HD[/I][/COLOR]' # if 'trailer' in info: # name = name + ' [COLOR green][I]Trailer[/I][/COLOR]' liz=xbmcgui.ListItem(label=html2text.html2text(name)) liz.setInfo( type='video', infoLabels=info ) liz.setArt({'icon': icon, 'thumb': icon, 'banner': icon, 'poster': icon, 'fanart': icon}) liz.setProperty('IsPlayable', 'true') #liz.setRating('einthusan', 4.3, 10, True) if 'trailer' in info: # xbmc.log('adding context menu item for playing trailer: '+info['trailer'], xbmc.LOGINFO) liz.addContextMenuItems([ ('Play trailer', 'RunPlugin(%s)' % info['trailer'], ) ]) ok=xbmcplugin.addDirectoryItem(handle=_plugin_handle, url=u, listitem=liz, isFolder=False) return ok
def add_dir(name, id, mode, icon, fanart=None, info=None, genre_id=None, content_type='videos'): ok = True u = addon_url + "?id=" + urllib.quote_plus(id) + "&mode=" + str(mode) if genre_id is not None: u += "&genre_id=%s" % genre_id listitem = xbmcgui.ListItem(name) if fanart is None: fanart = FANART listitem.setArt({ 'icon': icon, 'thumb': icon, 'poster': icon, 'fanart': fanart }) if info is not None: listitem.setInfo(type="video", infoLabels=info) ok = xbmcplugin.addDirectoryItem(handle=addon_handle, url=u, listitem=listitem, isFolder=True) xbmcplugin.setContent(addon_handle, content_type) return ok
def add_to_xbmc_directory(self, is_folder=False, item=None, url=None, **ka): if not xbmcplugin.addDirectoryItem(self.handle, url, item, is_folder, self.total_put): return False self.total_put += 1 return True
def download_subs(link, referrer, filename): """ Download selected subs :param link: str - a download link for the subs. :param referrer: str - a referer URL for the episode page (required by addic7ed.com). :param filename: str - the name of the video-file being played. The function must add a single ListItem instance with one property: label - the download location for subs. """ # Re-create a download location in a temporary folder if not os.path.exists(profile): os.mkdir(profile) if os.path.exists(temp_dir): shutil.rmtree(temp_dir) os.mkdir(temp_dir) # Combine a path where to download the subs filename = os.path.splitext(filename)[0] + '.srt' subspath = os.path.join(temp_dir, filename) # Download the subs from addic7ed.com try: parser.download_subs(link, referrer, subspath) except Add7ConnectionError: logger.error('Unable to connect to addic7ed.com') dialog.notification(get_ui_string(32002), get_ui_string(32005), 'error') except DailyLimitError: dialog.notification(get_ui_string(32002), get_ui_string(32003), 'error', 3000) logger.error('Exceeded daily limit for subs downloads.') else: # Create a ListItem for downloaded subs and pass it # to the Kodi subtitles engine to move the downloaded subs file # from the temp folder to the designated # location selected by 'Subtitle storage location' option # in 'Settings > Video > Subtitles' section. # A 2-letter language code will be added to subs filename. list_item = xbmcgui.ListItem(label=subspath) xbmcplugin.addDirectoryItem(handle=handle, url=subspath, listitem=list_item, isFolder=False) dialog.notification(get_ui_string(32000), get_ui_string(32001), icon, 3000, False) logger.info('Subs downloaded.')
def add_directory_item( self, title, description, content_id, action, section_next, item=None, ): # Create a list item with a text label and a thumbnail image. list_item = xbmcgui.ListItem(label=title) # 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. if item and item.get('image') is not None: cover_image, list_image = MxPlayerPlugin.get_images(item) list_item.setArt({ 'poster': list_image or cover_image, 'thumb': list_image or cover_image, 'icon': list_image or cover_image, 'fanart': cover_image or list_image }) #web_pdb.set_trace() list_item.setInfo( 'video', { 'count': content_id, 'title': title, 'genre': self.get_genre(item), 'plot': description, 'mediatype': 'tvshow' }) # Create a URL for a plugin recursive call. # Example: plugin://plugin.video.example/?action=listing&category=Animals url = self.get_url(action=action, content_id=content_id, section_next=section_next, title=title) # is_folder = True means that this item opens a sub-list of lower level items. is_folder = True # Add our item to the Kodi virtual folder listing. xbmcplugin.addDirectoryItem(self.handle, url, list_item, is_folder)
def display_subs(subs_list, episode_url, filename): """ Display the list of found subtitles :param subs_list: the list or generator of tuples (subs item, synced) :param episode_url: the URL for the episode page on addic7ed.com. It is needed for downloading subs as 'Referer' HTTP header. :param filename: the name of the video-file being played. Each item in the displayed list is a ListItem instance with the following properties: - label: Kodi language name (e.g. 'English') - label2: a descriptive text for subs - thumbnailImage: a 2-letter language code (e.g. 'en') to display a country flag. - 'hearing_imp': if 'true' then 'CC' icon is displayed for the list item. - 'sync': if 'true' then 'SYNC' icon is displayed for the list item. - url: a plugin call URL for downloading selected subs. """ subs_list = sorted( _detect_synced_subs(subs_list, filename), key=lambda i: i[1], reverse=True ) for item, synced in subs_list: if addon.getSetting('do_login') != 'true' and item.unfinished: continue list_item = xbmcgui.ListItem(label=item.language, label2=item.version) list_item.setArt( {'thumb': xbmc.convertLanguage(item.language, xbmc.ISO_639_1)} ) if item.hi: list_item.setProperty('hearing_imp', 'true') if synced: list_item.setProperty('sync', 'true') url = '{0}?{1}'.format( sys.argv[0], urlparse.urlencode( {'action': 'download', 'link': item.link, 'ref': episode_url, 'filename': filename} ) ) xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=list_item, isFolder=False)
def add_item(self, item): verify_age = item.get('verify_age', False) data = { 'mode': item['mode'], 'title': item['title'], 'id': item.get('id', ''), 'params': item.get('params', ''), 'verify_age': verify_age } art = { 'thumb': item.get('thumb', self.plugin.addon_icon), 'poster': item.get('thumb', self.plugin.addon_icon), 'fanart': item.get('fanart', self.plugin.addon_fanart) } labels = { 'title': item['title'], 'plot': item.get('plot', item['title']), 'premiered': item.get('date', ''), 'episode': item.get('episode', 0) } if verify_age: labels['mpaa'] = 'PG-18' listitem = xbmcgui.ListItem(item['title']) listitem.setArt(art) listitem.setInfo(type='Video', infoLabels=labels) if 'play' in item['mode']: self.cache = False self.video = True folder = False listitem.addStreamInfo('video', {'duration': item.get('duration', 0)}) listitem.setProperty('IsPlayable', item.get('playable', 'false')) else: folder = True if item.get('cm', None): listitem.addContextMenuItems(item['cm']) xbmcplugin.addDirectoryItem(self.plugin.addon_handle, self.plugin.build_url(data), listitem, folder)
def display_subs(subs_list, episode_url, filename): """ Display the list of found subtitles :param subs_list: the list or generator of tuples (subs item, synced) :param episode_url: the URL for the episode page on addic7ed.com. It is needed for downloading subs as 'Referer' HTTP header. :param filename: the name of the video-file being played. Each item in the displayed list is a ListItem instance with the following properties: - label: Kodi language name (e.g. 'English') - label2: a descriptive text for subs - thumbnailImage: a 2-letter language code (e.g. 'en') to display a country flag. - 'hearing_imp': if 'true' then 'CC' icon is displayed for the list item. - 'sync': if 'true' then 'SYNC' icon is displayed for the list item. - url: a plugin call URL for downloading selected subs. """ subs_list = sorted( _detect_synced_subs(subs_list, filename), key=lambda i: i[1], reverse=True ) for item, synced in subs_list: if item.unfinished: continue list_item = xbmcgui.ListItem(label=item.language, label2=item.version) list_item.setArt( {'thumb': xbmc.convertLanguage(item.language, xbmc.ISO_639_1)} ) if item.hi: list_item.setProperty('hearing_imp', 'true') if synced: list_item.setProperty('sync', 'true') url = '{0}?{1}'.format( sys.argv[0], urlparse.urlencode( {'action': 'download', 'link': item.link, 'ref': episode_url, 'filename': filename} ) ) xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=list_item, isFolder=False)
def addDir(name, mode, sitemode, url='', thumb='', fanart='', infoLabels=None, totalItems=0, cm=None, page=1, options=''): name = str(py2_encode(name)) u = { 'url': py2_encode(url), 'mode': mode, 'sitemode': sitemode, 'name': name, 'page': page, 'opt': options } url = '{}?{}'.format(sys.argv[0], urlencode(u)) if not fanart or fanart == na: fanart = def_fanart if not thumb: thumb = def_fanart item = xbmcgui.ListItem(name, thumbnailImage=thumb) item.setProperty('fanart_image', fanart) item.setProperty('IsPlayable', 'false') item.setArt({'Poster': thumb}) if infoLabels: item.setInfo(type='Video', infoLabels=getInfolabels(infoLabels)) if 'TotalSeasons' in infoLabels.keys(): item.setProperty('TotalSeasons', str(infoLabels['TotalSeasons'])) if cm: item.addContextMenuItems(cm) xbmcplugin.addDirectoryItem(var.pluginhandle, url=url, listitem=item, isFolder=sitemode not in ('switchUser', 'updateAll'), totalItems=totalItems)
def addLink(name, handleID, url, mode, info=None, art=None, total=0, contextMenu=None, properties=None): global CONTENT_TYPE, ADDON_URL log('Adding link %s' % name) link = xbmcgui.ListItem(name) if mode == 'info': link.setProperty('IsPlayable', 'false') else: link.setProperty('IsPlayable', 'true') if info is None: link.setInfo(type='Video', infoLabels={ 'mediatype': 'video', 'title': name }) else: if 'mediatype' in info: CONTENT_TYPE = '%ss' % info['mediatype'] link.setInfo(type='Video', infoLabels=info) if art is None: link.setArt({'thumb': ICON, 'fanart': FANART}) else: link.setArt(art) if contextMenu is not None: link.addContextMenuItems(contextMenu) if properties is not None: log('Adding Properties: %s' % str(properties)) for key, value in properties.items(): link.setProperty(key, str(value)) try: name = urlLib.quote_plus(name) except: name = urlLib.quote_plus(strip(name)) if url != '': url = ('%s?url=%s&mode=%s&name=%s' % (ADDON_URL, urlLib.quote_plus(url), mode, name)) else: url = ('%s?mode=%s&name=%s' % (ADDON_URL, mode, name)) xbmcplugin.addDirectoryItem(handle=handleID, url=url, listitem=link, totalItems=total) xbmcplugin.addSortMethod( handle=handleID, sortMethod=xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
def addDir(name, url, mode, iconimage, page): u = sys.argv[0] + '?url=' + urllib_parse.quote_plus(url) + '&mode=' + str(mode) +\ '&name=' + urllib_parse.quote_plus(name) + '&page=' + str(page) ok = True liz = xbmcgui.ListItem(name) liz.setArt({'thumb': iconimage, 'icon': 'DefaultFolder.png'}) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) 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 addDir(self, item, mode=HbogoConstants.ACTION_LIST, media_type=None): if self.lograwdata: self.log("Adding Dir: " + str(item) + " MODE: " + str(mode)) media_type = "tvshow" plot = "" try: plot = py2_encode(item.find('description').text) except AttributeError: pass except Exception: self.log("Error in description processing: " + traceback.format_exc()) directory_url = '%s?%s' % (self.base_url, urlencode({ 'url': item.find('link').text, 'mode': mode, 'name': py2_encode(item.find('title').text), })) series_name = "" try: series_name = py2_encode(item.find('clearleap:series', namespaces=self.NAMESPACES).text) except AttributeError: pass except Exception: self.log("Error in searies name processing: " + traceback.format_exc()) thumb = self.get_thumbnail_url(item) liz = xbmcgui.ListItem(item.find('title').text) liz.setArt({ 'thumb': thumb, 'poster': thumb, 'banner': thumb, 'fanart': thumb }) liz.setInfo(type="Video", infoLabels={ "mediatype": media_type, "tvshowtitle": series_name, "title": item.find('title').text, "Plot": plot }) liz.setProperty('isPlayable', "false") xbmcplugin.addDirectoryItem(handle=self.handle, url=directory_url, listitem=liz, isFolder=True)
def build_main_menu(self): """ Builds the main menu of the plugin: All shows News Categories """ log('build_main_menu', debug=self.debug()) main_menu_list = [ { # All shows 'name': LANGUAGE(30050), 'mode': 10, 'isFolder': True, 'displayItem': True, }, { # News 'name': LANGUAGE(30051), 'mode': 11, 'isFolder': True, 'displayItem': True, }, { # Categories 'name': LANGUAGE(30052), 'mode': 12, 'isFolder': True, 'displayItem': True, }, ] for menu_item in main_menu_list: if menu_item['displayItem']: list_item = xbmcgui.ListItem(menu_item['name']) list_item.setProperty('IsPlayable', 'false') list_item.setArt({'thumb': self.icon()}) purl = self.build_url(mode=menu_item['mode'], name=menu_item['name']) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=purl, listitem=list_item, isFolder=menu_item['isFolder'])
def add_to_xbmc_directory(self, is_folder=False, item=None, url=None, **ka): if not xbmcplugin.addDirectoryItem(self.handle, url, item, is_folder, self.total_put): return False self.total_put += 1 return True
def download_subs(link, referrer, filename): """ Download selected subs :param link: str - a download link for the subs. :param referrer: str - a referer URL for the episode page (required by addic7ed.com). :param filename: str - the name of the video-file being played. The function must add a single ListItem instance with one property: label - the download location for subs. """ # Re-create a download location in a temporary folder if xbmcvfs.exists(temp_dir): shutil.rmtree(temp_dir) xbmcvfs.mkdirs(temp_dir) # Combine a path where to download the subs subspath = os.path.join(temp_dir, filename[:-3] + 'srt') # Download the subs from addic7ed.com try: parser.download_subs(link, referrer, subspath) except Add7ConnectionError: logger.error('Unable to connect to addic7ed.com') dialog.notification(get_ui_string(32002), get_ui_string(32005), 'error') except DailyLimitError: dialog.notification(get_ui_string(32002), get_ui_string(32003), 'error', 3000) logger.error('Exceeded daily limit for subs downloads.') else: # Create a ListItem for downloaded subs and pass it # to the Kodi subtitles engine to move the downloaded subs file # from the temp folder to the designated # location selected by 'Subtitle storage location' option # in 'Settings > Video > Subtitles' section. # A 2-letter language code will be added to subs filename. list_item = xbmcgui.ListItem(label=subspath) xbmcplugin.addDirectoryItem(handle=handle, url=subspath, listitem=list_item, isFolder=False) dialog.notification(get_ui_string(32000), get_ui_string(32001), icon, 3000, False) logger.notice('Subs downloaded.')
def item(params, folder=True): url = get_url(params) name = params.get("name") if name: name = name else: name = 'Unknow' iconimage = params.get("iconimage") fanart = params.get("fanart") description = params.get("description") if description: description = description else: description = '' mediatype = params.get("mediatype") if six.PY3: li = xbmcgui.ListItem(name) if iconimage: li.setArt({"icon": "DefaultVideo.png", "thumb": iconimage}) else: if not iconimage: iconimage = '' li = xbmcgui.ListItem(name, iconImage=iconimage, thumbnailImage=iconimage) if mediatype: try: li.setInfo('video', {'mediatype': str(mediatype)}) except: pass if playable and not playable == 'false': li.setProperty('IsPlayable', 'true') li.setInfo(type="Video", infoLabels={"Title": name, "Plot": description}) if fanart: li.setProperty('fanart_image', fanart) else: li.setProperty('fanart_image', fanart_default) xbmcplugin.addDirectoryItem(handle=handle, url=url, listitem=li, isFolder=folder)
def addVideo(name, asin, infoLabels, cm=None, export=False): g = Globals() s = Settings() u = {'asin': asin, 'mode': 'PlayVideo', 'name': py2_encode(name), 'adult': infoLabels['isAdult']} url = '{}?{}'.format(g.pluginid, urlencode(u)) bitrate = '0' streamtypes = {'live': 2} item = xbmcgui.ListItem(name) item.setArt({'fanart': infoLabels['Fanart'], 'poster': infoLabels['Thumb'], 'thumb': infoLabels['Thumb']}) item.addStreamInfo('audio', {'codec': 'ac3', 'channels': int(infoLabels['AudioChannels'])}) item.setProperty('IsPlayable', str(s.playMethod == 3).lower()) if 'Poster' in infoLabels.keys(): item.setArt({'tvshow.poster': infoLabels['Poster']}) if infoLabels['TrailerAvailable']: infoLabels['Trailer'] = url + '&trailer=1&selbitrate=0' url += '&trailer=%s' % streamtypes.get(infoLabels['contentType'], 0) if [k for k in ['4k', 'uhd', 'ultra hd'] if k in (infoLabels.get('TVShowTitle', '') + name).lower()]: bitrate = '-1' item.addStreamInfo('video', {'width': 3840, 'height': 2160}) if s.uhdAndroid: item.setProperty('IsPlayable', 'false') elif infoLabels['isHD']: item.addStreamInfo('video', {'width': 1920, 'height': 1080}) else: item.addStreamInfo('video', {'width': 720, 'height': 480}) if export: url += '&selbitrate=' + bitrate g.amz.Export(infoLabels, url) else: cm = cm if cm else [] cm.insert(0, (getString(30101), 'Action(ToggleWatched)')) cm.insert(1, (getString(30102), 'RunPlugin({})'.format(url + '&selbitrate=1'))) item.setInfo(type='Video', infoLabels=getInfolabels(infoLabels)) item.addContextMenuItems(cm) url += '&selbitrate=' + bitrate xbmcplugin.addDirectoryItem(g.pluginhandle, url, item, isFolder=False)
def display(self): handle = _handle() items = [i for i in self.items if i] if not items and self.no_items_label: label = _(self.no_items_label, _label=True) if self.no_items_method == 'dialog': gui.ok(label, heading=self.title) return resolve() else: items.append(Item( label=label, is_folder=False, )) for item in items: if self.thumb and not item.art.get('thumb'): item.art['thumb'] = self.thumb if self.fanart and not item.art.get('fanart'): item.art['fanart'] = self.fanart li = item.get_li() xbmcplugin.addDirectoryItem(handle, item.path, li, item.is_folder) if self.content: xbmcplugin.setContent(handle, self.content) if self.title: xbmcplugin.setPluginCategory(handle, self.title) for sort_method in self.sort_methods: xbmcplugin.addSortMethod(handle, sort_method) xbmcplugin.endOfDirectory(handle, succeeded=True, updateListing=self.updateListing, cacheToDisc=self.cacheToDisc) common_data = userdata.Userdata(COMMON_ADDON) plugin_msg = common_data.get('_next_plugin_msg') if plugin_msg: common_data.delete('_next_plugin_msg') gui.ok(plugin_msg)
def addDir(name, url, mode, iconimage): u = sys.argv[0] + "?url=" + urllib_parse.quote_plus(url) + "&mode=" + str(mode) \ + "&name=" + urllib_parse.quote_plus(name) ok = True liz = xbmcgui.ListItem(name) liz.setArt({'thumb': iconimage, 'icon': 'DefaultVideo.png', 'poster': iconimage}) liz.setInfo(type='Video', infoLabels={'Title': name}) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) return ok
def addLink(self, title, mode): if self.lograwdata: self.log("Adding Link: " + str(title) + " MODE: " + str(mode)) media_info = self.construct_media_info(title) guid = py2_encode(title.find('guid').text) item_url = '%s?%s' % (self.base_url, urlencode({ 'url': 'PLAY', 'mode': mode, 'cid': guid, })) liz = xbmcgui.ListItem(media_info["info"]["title"]) liz.setArt(media_info["art"]) liz.setInfo(type="Video", infoLabels=media_info["info"]) liz.addStreamInfo('video', {'width': 1920, 'height': 1080, 'aspect': 1.78, 'codec': 'h264'}) liz.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) liz.addContextMenuItems(items=self.genContextMenu(guid)) liz.setProperty("IsPlayable", "true") xbmcplugin.addDirectoryItem(handle=self.handle, url=item_url, listitem=liz, isFolder=False)
def add_stream(name, id, stream_type, icon, fanart, info=None): ok = True u=addon_url+"?id="+urllib.quote_plus(id)+"&mode="+str(103)+"&type="+urllib.quote_plus(stream_type) listitem=xbmcgui.ListItem(name) if fanart is None: fanart = FANART listitem.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'fanart': fanart}) listitem.setProperty("IsPlayable", "true") if info is not None: listitem.setInfo( type="video", infoLabels=info) ok = xbmcplugin.addDirectoryItem(handle=addon_handle,url=u,listitem=listitem,isFolder=False) xbmcplugin.setContent(addon_handle, stream_type) return ok
def browse(): args = plugin.args if 'path' not in args: # back navigation workaround: just silently fail and we'll # eventually end outside the plugin dir xbmcplugin.endOfDirectory(plugin.handle, succeeded=False) return current_path = args['path'][0] if not current_path.endswith('/'): current_path += '/' dirs = [] files = [] if xbmcvfs.exists(current_path): dirs, files = xbmcvfs.listdir(current_path) for name in dirs: li = ListItem(name) path = os.path.join(current_path, name) params = { b'path': path, b'title': args['title'][0], } if 'fanart' in args: li.setArt({'fanart': args['fanart'][0]}) params.update({b'fanart': args['fanart'][0]}) url = 'plugin://context.item.extras/?' + urlencode(params) xbmcplugin.addDirectoryItem(plugin.handle, url, li, isFolder=True) for name in files: li = ListItem(name) if 'fanart' in args: li.setArt({'fanart': args['fanart'][0]}) url = os.path.join(current_path, py2_decode(name)) xbmcplugin.addDirectoryItem(plugin.handle, url, li, isFolder=False) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(plugin.handle)
def createPlayAllItem(name, pluginhandle, stream_info=False): play_all_parameters = {"mode": "playlist"} play_all_url = build_kodi_url(play_all_parameters) play_all_item = xbmcgui.ListItem(label=name, offscreen=True) if stream_info: description = stream_info['description'] play_all_item.setArt({ 'thumb': stream_info['teaser_image'], 'poster': stream_info['teaser_image'] }) else: description = "" play_all_item.setInfo(type="Video", infoLabels={ "Title": name, "Plot": description }) xbmcplugin.addDirectoryItem(pluginhandle, play_all_url, play_all_item, isFolder=False, totalItems=-1)
def addDir(li, label, action, dirID, fanart, thumb, fparams, summary='', tagline='', mediatype='', cmenu=True): PLog('addDir:') PLog(type(label)) label=py2_encode(label) PLog('addDir - label: {0}, action: {1}, dirID: {2}'.format(label, action, dirID)) PLog(type(summary)); PLog(type(tagline)); summary=py2_encode(summary); tagline=py2_encode(tagline); fparams=py2_encode(fparams); fanart=py2_encode(fanart); thumb=py2_encode(thumb); PLog('addDir - summary: {0}, tagline: {1}, mediatype: {2}, cmenu: {3}'.format(summary, tagline, mediatype, cmenu)) li.setLabel(label) # Kodi Benutzeroberfläche: Arial-basiert für arabic-Font erf. PLog('summary, tagline: %s, %s' % (summary, tagline)) Plot = '' if tagline: Plot = tagline if summary: Plot = "%s\n\n%s" % (Plot, summary) if mediatype == 'video': # "video", "music" setzen: List- statt Dir-Symbol li.setInfo(type="video", infoLabels={"Title": label, "Plot": Plot, "mediatype": "video"}) isFolder = False # nicht bei direktem Player-Aufruf - OK mit setResolvedUrl li.setProperty('IsPlayable', 'true') else: li.setInfo(type="video", infoLabels={"Title": label, "Plot": Plot}) li.setProperty('IsPlayable', 'false') isFolder = True li.setArt({'thumb':thumb, 'icon':thumb, 'fanart':fanart}) xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_UNSORTED) PLog('PLUGIN_URL: ' + PLUGIN_URL) # plugin://plugin.video.ardundzdf/ PLog('HANDLE: ' + str(HANDLE)) url = PLUGIN_URL+"?action="+action+"&dirID="+dirID+"&fanart="+fanart+"&thumb="+thumb+quote_plus(fparams) PLog("addDir_url: " + unquote_plus(url)) xbmcplugin.addDirectoryItem(handle=HANDLE,url=url,listitem=li,isFolder=isFolder) PLog('addDir_End') return
def list_systems(): systems = util.get_systems() for system_key in sorted(systems, key=lambda k: systems[k]['name']): system = systems[system_key] listitem = xbmcgui.ListItem() listitem.setLabel(system['name']) listitem.setArt({'thumb': system['icon']}) context_items = [ ('Rename', "RunPlugin({0}?action=rename&system={1})".format( sys.argv[0], system_key)), ('Set Icon', "RunPlugin({0}?action=set_icon&system={1})".format( sys.argv[0], system_key)), ('Set to Default Boot', "RunPlugin({0}?action=defaultboot&system={1})".format( sys.argv[0], system_key)), ('Show Boot Commands', "RunPlugin({0}?action=showbootcommands&system={1})".format( sys.argv[0], system_key)), ] if util.get_system_info(system_key).get('boot-back', None): context_items.extend( (('Install Boot-Back', "RunPlugin({0}?action=install&system={1})".format( sys.argv[0], system_key)), )) listitem.addContextMenuItems(context_items) action = "{0}?action=boot&system={1}".format(sys.argv[0], system_key) xbmcplugin.addDirectoryItem(int(sys.argv[1]), action, listitem, isFolder=False) xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=False)