我们从Python开源项目中,提取了以下16个代码示例,用于说明如何使用xbmcplugin.SORT_METHOD_LABEL。
def list_categories(params): listing = [] categories = api.get_categories() if categories: for item in categories: li = category_to_kodi_item(item) listing.append(li) # Item label sortable_by = ( xbmcplugin.SORT_METHOD_LABEL ) return common.plugin.create_listing( listing, #succeeded = True, #if False Kodi won’t open a new listing and stays on the current level. #update_listing = False, #if True, Kodi won’t open a sub-listing but refresh the current one. #cache_to_disk = True, #cache this view to disk. #sort_methods = sortable_by, #he list of integer constants representing virtual folder sort methods. #view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing). #content = None #string - current plugin content, e.g. ‘movies’ or ‘episodes’. )
def list_selection(params): listing = [] selection = scraper.get_selection() if selection: for media_node in selection: li = media_to_kodi_item(media_node) listing.append(li) # Item label sortable_by = ( xbmcplugin.SORT_METHOD_LABEL ) return common.plugin.create_listing( listing, #succeeded = True, #if False Kodi won’t open a new listing and stays on the current level. #update_listing = False, #if True, Kodi won’t open a sub-listing but refresh the current one. #cache_to_disk = True, #cache this view to disk. #sort_methods = sortable_by, #he list of integer constants representing virtual folder sort methods. #view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing). #content = None #string - current plugin content, e.g. ‘movies’ or ‘episodes’. )
def LIST_TVSHOWS(filter='', value=False, sortcol=False, sortaz=True, search=False, cmmode=0): import tv as tvDB if 'year' in filter: value = value.replace('0 -', '') shows = tvDB.loadTVShowdb(filter=filter, value=value, sortcol=sortcol) count = 0 for showdata in shows: count += 1 ADD_SHOW_ITEM(showdata, cmmode=cmmode) if not search: if sortaz: if 'year' not in filter: xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_VIDEO_RATING) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE) common.SetView('tvshows') return count
def rootDir(): print sys.argv nav = getNav() #Livesender liveChannelsDir() #Navigation der Ipad App for item in nav: if item.attrib['hide'] == 'true' or item.tag == 'item': continue url = common.build_url({'action': 'listPage', 'id': item.attrib['id']}) addDir(item.attrib['label'], url) li = xbmcgui.ListItem(item.attrib['label']) #Merkliste watchlistDir() #Suchfunktion url = common.build_url({'action': 'search'}) addDir('Suche', url) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
def listSeasonsFromSeries(series_id): url = skygo.baseUrl + '/sg/multiplatform/web/json/details/series/' + str(series_id) + '_global.json' r = requests.get(url) data = r.json()['serieRecap']['serie'] xbmcplugin.setContent(addon_handle, 'seasons') for season in data['seasons']['season']: url = common.build_url({'action': 'listSeason', 'id': season['id'], 'series_id': data['id']}) label = '%s - Staffel %02d' % (data['title'], season['nr']) li = xbmcgui.ListItem(label=label) li.setProperty('IsPlayable', 'false') li.setArt({'poster': skygo.baseUrl + season['path'], 'fanart': getHeroImage(data)}) li.setInfo('video', {'plot': data['synopsis'].replace('\n', '').strip()}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
def LIST_MOVIE_TYPES(type=False): import movies as moviesDB if not type: type = common.args.url if type: mode = 'LIST_MOVIES_FILTERED' for item in moviesDB.getMovieTypes(type): common.addDir(item, 'listmovie', mode, type) xbmcplugin.addSortMethod(common.pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(common.pluginhandle, updateListing=False)
def LIST_TVSHOWS_TYPES(type=False): import tv as tvDB if not type: type = common.args.url if type: mode = 'LIST_TVSHOWS_FILTERED' items = tvDB.getShowTypes(type) for item in items: common.addDir(item, 'listtv', mode, type) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(pluginhandle, updateListing=False)
def LIST_TV_SEASONS(seasons=False): seriesasin = common.args.url import tv as tvDB for asin in seriesasin.split(','): seasons = tvDB.loadTVSeasonsdb(seriesasin=asin).fetchall() for seasondata in seasons: ADD_SEASON_ITEM(seasondata) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) common.SetView('seasons')
def LIST_EPISODES_DB(owned=False, url=False): if not url: seriestitle = common.args.url import tv as tvDB for asin in seriestitle.split(','): episodes = tvDB.loadTVEpisodesdb(asin) for episodedata in episodes: ADD_EPISODE_ITEM(episodedata) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_EPISODE) common.SetView('episodes')
def listLiveTvChannelDirs(): data = getlistLiveChannelData() for tab in data: url = common.build_url({'action': 'listLiveTvChannels', 'channeldir_name': tab['tabName']}) li = xbmcgui.ListItem(label=tab['tabName'].title(), iconImage=icon_file) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
def listEpisodesFromSeason(series_id, season_id): url = skygo.baseUrl + '/sg/multiplatform/web/json/details/series/' + str(series_id) + '_global.json' r = requests.get(url) data = r.json()['serieRecap']['serie'] xbmcplugin.setContent(addon_handle, 'episodes') for season in data['seasons']['season']: if str(season['id']) == str(season_id): for episode in season['episodes']['episode']: #Check Altersfreigabe / Jugendschutzeinstellungen if 'parental_rating' in episode: if js_showall == 'false': if not skygo.parentalCheck(episode['parental_rating']['value'], play=False): continue url = common.build_url({'action': 'playVod', 'vod_id': episode['id']}) li = xbmcgui.ListItem() li.setProperty('IsPlayable', 'true') li.addContextMenuItems(getWatchlistContextItem({'type': 'Episode', 'data': episode}), replaceItems=False) info, episode = getInfoLabel('Episode', episode) li.setInfo('video', info) li.setLabel('%02d. %s' % (info['episode'], info['title'])) li.setArt({'poster': skygo.baseUrl + season['path'], 'fanart': getHeroImage(data), 'thumb': skygo.baseUrl + episode['webplayer_config']['assetThumbnail']}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=False) xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_EPISODE) xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION) xbmcplugin.addSortMethod(addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)
def show_sport_categories(self, sport): """ Creates the KODI list items for the contents of a sport selection. It loads the sport html page & parses the event lanes given :param sport: Chosen sport :type sport: string """ self.utils.log('(' + sport + ') Main Menu') _session = self.session.get_session() base_url = self.constants.get_base_url() sports = self.constants.get_sports_list() # load sport page from telekom url = base_url + '/' + sports.get(sport, {}).get('page') html = _session.get(url, verify=self.verify_ssl).text # parse sport page data events = [] check_soup = BeautifulSoup(html, 'html.parser') content_groups = check_soup.find_all('div', class_='content-group') for content_group in content_groups: headline = content_group.find('h2') event_lane = content_group.find('event-lane') if headline: if event_lane is not None: events.append((headline.get_text().encode( 'utf-8'), event_lane.attrs.get('prop-url'))) # add directory item for each event for event in events: url = self.utils.build_url({'for': sport, 'lane': event[1]}) list_item = xbmcgui.ListItem(label=self.utils.capitalize(event[0])) 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) # Add static folder items (if available) # self.__add_static_folders() xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(self.plugin_handle)
def build_profiles_listing(self, profiles, action, build_url): """ Builds the profiles list Kodi screen :param profiles: list of user profiles :type profiles: list :param action: action paramter to build the subsequent routes :type action: str :param build_url: function to build the subsequent routes :type build_url: fn :returns: bool -- List could be build """ # init html parser for entity decoding html_parser = HTMLParser() # build menu items for every profile for profile in profiles: # load & encode profile data enc_profile_name = profile.get('profileName', '').encode('utf-8') unescaped_profile_name = html_parser.unescape(enc_profile_name) profile_guid = profile.get('guid') # build urls url = build_url({'action': action, 'profile_id': profile_guid}) autologin_url = build_url({ 'action': 'save_autologin', 'autologin_id': profile_guid, 'autologin_user': enc_profile_name}) # add list item list_item = xbmcgui.ListItem( label=unescaped_profile_name, iconImage=profile.get('avatar')) list_item.setProperty( key='fanart_image', value=self.default_fanart) # add context menu options auto_login = ( self.get_local_string(30053), 'RunPlugin(' + autologin_url + ')') list_item.addContextMenuItems(items=[auto_login]) # add directory & sorting options xbmcplugin.addDirectoryItem( handle=self.plugin_handle, url=url, listitem=list_item, isFolder=True) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) return xbmcplugin.endOfDirectory(handle=self.plugin_handle)
def build_user_sub_listing(self, video_list_ids, type, action, build_url): """ Builds the video lists screen for user subfolders (genres & recommendations) Parameters ---------- video_list_ids : :obj:`dict` of :obj:`str` List of video lists type : :obj:`str` List type (genre or recommendation) action : :obj:`str` Action paramter to build the subsequent routes build_url : :obj:`fn` Function to build the subsequent routes Returns ------- bool List could be build """ for video_list_id in video_list_ids: li = xbmcgui.ListItem( label=video_list_ids[video_list_id]['displayName'], iconImage=self.default_fanart) li.setProperty('fanart_image', self.default_fanart) url = build_url({'action': action, 'video_list_id': video_list_id}) xbmcplugin.addDirectoryItem( handle=self.plugin_handle, url=url, listitem=li, isFolder=True) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(self.plugin_handle) self.set_custom_view(VIEW_FOLDER) return True
def build_season_listing(self, seasons_sorted, build_url): """Builds the season list screen for a show Parameters ---------- seasons_sorted : :obj:`list` of :obj:`dict` of :obj:`str` Sorted list of season entries build_url : :obj:`fn` Function to build the subsequent routes Returns ------- bool List could be build """ for season in seasons_sorted: li = xbmcgui.ListItem(label=season['text']) # add some art to the item li = self._generate_art_info(entry=season, li=li) # add list item info li, infos = self._generate_entry_info( entry=season, li=li, base_info={'mediatype': 'season'}) li = self._generate_context_menu_items(entry=season, li=li) params = {'action': 'episode_list', 'season_id': season['id']} if 'tvshowtitle' in infos: title = infos.get('tvshowtitle', '').encode('utf-8') params['tvshowtitle'] = base64.urlsafe_b64encode(title) url = build_url(params) xbmcplugin.addDirectoryItem( handle=self.plugin_handle, url=url, listitem=li, isFolder=True) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_LASTPLAYED) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.endOfDirectory(self.plugin_handle) self.set_custom_view(VIEW_SEASON) return True
def listAssets(asset_list, isWatchlist=False): for item in asset_list: isPlayable = False li = xbmcgui.ListItem(label=item['label'], iconImage=icon_file) if item['type'] in ['Film', 'Episode', 'Sport', 'Clip', 'Series', 'live', 'searchresult']: isPlayable = True #Check Altersfreigabe / Jugendschutzeinstellungen if 'parental_rating' in item['data']: if js_showall == 'false': if not skygo.parentalCheck(item['data']['parental_rating']['value'], play=False): continue info, item['data'] = getInfoLabel(item['type'], item['data']) # xbmc.log( "Debug_Info Current item Element: %s" % (item) ) li.setInfo('video', info) li.setLabel(info['title']) li.setArt({'poster': getPoster(item['data']), 'fanart': getHeroImage(item['data'])}) if item['type'] in ['Film']: xbmcplugin.setContent(addon_handle, 'movies') if xbmcaddon.Addon().getSetting('lookup_tmdb_data') == 'true' and 'TMDb_poster_path' in item['data']: poster_path = item['data']['TMDb_poster_path'] else: poster_path = getPoster(item['data']) # xbmc.log('Debug-Info: Current Poster in item: %s' % getPoster(item['data']) ) # xbmc.log('Debug-Info: Current Poster in info: %s' % item['data']['TMDb_poster_path'] ) li.setArt({'poster': poster_path}) elif item['type'] in ['Series']: xbmcplugin.setContent(addon_handle, 'tvshows') isPlayable = False elif item['type'] in ['Episode']: xbmcplugin.setContent(addon_handle, 'episodes') elif item['type'] in ['Sport', 'Clip']: xbmcplugin.setContent(addon_handle, 'files') li.setArt({'thumb': getHeroImage(item['data'])}) elif item['type'] == 'searchresult': xbmcplugin.setContent(addon_handle, 'movies') elif item['type'] == ('live'): xbmcplugin.setContent(addon_handle, 'files') if 'TMDb_poster_path' in item['data']: poster = item['data']['TMDb_poster_path'] elif 'mediainfo' in item['data']: poster = getPoster(item['data']['mediainfo']) else: poster = getPoster(item['data']['channel']) fanart = skygo.baseUrl + item['data']['event']['image'] if item['data']['channel']['name'].find('News') == -1 else skygo.baseUrl + '/bin/Picture/817/C_1_Picture_7179_content_4.jpg' thumb = skygo.baseUrl + item['data']['event']['image'] if item['data']['channel']['name'].find('News') == -1 else getChannelLogo(item['data']['channel']) li.setArt({'poster': poster, 'fanart': fanart, 'thumb': thumb}) #add contextmenu item for watchlist to playable content - not for live and clip content if isPlayable and not item['type'] in ['live', 'Clip']: li.addContextMenuItems(getWatchlistContextItem(item, isWatchlist), replaceItems=False) li.setProperty('IsPlayable', str(isPlayable).lower()) xbmcplugin.addDirectoryItem(handle=addon_handle, url=item['url'], listitem=li, isFolder=(not isPlayable)) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(handle=addon_handle, sortMethod=xbmcplugin.SORT_METHOD_DURATION) xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=True)