我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用xbmcplugin.endOfDirectory()。
def show_main_menu(): """Show the main categories This is typically: Shows, News, Movies, Live """ checkAccountChange() html = callServiceApi('/') processed = [] category_ids = common.parseDOM(html, 'a', ret='data-id') for id in category_ids: name = common.parseDOM(html, 'a', attrs={'data-id': id})[0] href = common.parseDOM(html, 'a', attrs={'data-id': id}, ret='href')[0] if id not in processed: addDir(name, href, Mode.SUB_MENU, 'icon.png', data_id=id) processed.append(id) addDir('Clear cookies', '/', Mode.CLEAR_COOKIES, 'icon.png', isFolder=False) xbmcplugin.endOfDirectory(thisPlugin)
def showShows(category_url): """Display all shows under a sub category params: category_url: a sub category is a unique id """ showListData = get_show_list(category_url) if showListData is None: xbmcplugin.endOfDirectory(thisPlugin) return for show_id, (title, thumbnail) in showListData.iteritems(): addDir(title, str(show_id), Mode.SHOW_INFO, thumbnail) xbmcplugin.addSortMethod(thisPlugin, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) xbmcplugin.endOfDirectory(thisPlugin)
def list_streams(streams): stream_list = [] # iterate over the contents of the dictionary songs to build the list for stream in streams: # create a list item using the stream's name for the label li = xbmcgui.ListItem(label=stream['name']) # set the thumbnail image li.setArt({'thumb': stream['logo']}) # set the list item to playable li.setProperty('IsPlayable', 'true') # build the plugin url for Kodi url = build_url({'mode': 'stream', 'url': stream['url'], 'title': stream['name']}) # add the current list item to a list stream_list.append((url, li, False)) # add list to Kodi per Martijn # http://forum.kodi.tv/showthread.php?tid=209948&pid=2094170#pid2094170 xbmcplugin.addDirectoryItems(addon_handle, stream_list, len(stream_list)) # set the content of the directory xbmcplugin.setContent(addon_handle, 'songs') xbmcplugin.endOfDirectory(addon_handle)
def list_podcast_radios(radios): radio_list = [] # iterate over the contents of the list of radios for radio in sorted(radios, key=operator.itemgetter('name')): url = build_url({'mode': 'podcasts-radio', 'foldername': radio['name'], 'url': radio['url'], 'name': radio['name']}) li = xbmcgui.ListItem(radio['name'], iconImage='DefaultFolder.png') radio_list.append((url, li, True)) # add list to Kodi per Martijn # http://forum.kodi.tv/showthread.php?tid=209948&pid=2094170#pid2094170 xbmcplugin.addDirectoryItems(addon_handle, radio_list, len(radio_list)) # set the content of the directory xbmcplugin.setContent(addon_handle, 'songs') xbmcplugin.endOfDirectory(addon_handle)
def list_podcast_programs(programs): program_list = [] # iterate over the contents of the list of programs for program in programs: url = build_url({'mode': 'podcasts-radio-program', 'foldername': urllib.quote(program['name'].encode('utf8')), 'url': program['url'], 'name': urllib.quote(program['name'].encode('utf8')), 'radio': program['radio']}) li = xbmcgui.ListItem(program['name'], iconImage='DefaultFolder.png') program_list.append((url, li, True)) # add list to Kodi per Martijn # http://forum.kodi.tv/showthread.php?tid=209948&pid=2094170#pid2094170 xbmcplugin.addDirectoryItems(addon_handle, program_list, len(program_list)) # set the content of the directory xbmcplugin.setContent(addon_handle, 'songs') xbmcplugin.endOfDirectory(addon_handle)
def __init__(self): try: self.addon = xbmcaddon.Addon(id=ADDON_ID) self.win = xbmcgui.Window(10000) self.cache = SimpleCache() auth_token = self.get_authkey() if auth_token: self.parse_params() self.sp = spotipy.Spotify(auth=auth_token) me = self.sp.me() self.userid = me["id"] self.usercountry = me["country"] self.local_playback, self.playername, self.connect_id = self.active_playback_device() if self.action: action = "self." + self.action eval(action)() else: self.browse_main() self.precache_library() else: xbmcplugin.endOfDirectory(handle=self.addon_handle) except Exception as exc: log_exception(__name__, exc) xbmcplugin.endOfDirectory(handle=self.addon_handle)
def browse_topartists(self): xbmcplugin.setContent(self.addon_handle, "artists") result = self.sp.current_user_top_artists(limit=20, offset=0) cachestr = "spotify.topartists.%s" % self.userid checksum = self.cache_checksum(result["total"]) items = self.cache.get(cachestr, checksum=checksum) if not items: count = len(result["items"]) while result["total"] > count: result["items"] += self.sp.current_user_top_artists(limit=20, offset=count)["items"] count += 50 items = self.prepare_artist_listitems(result["items"]) self.cache.set(cachestr, items, checksum=checksum) self.add_artist_listitems(items) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.endOfDirectory(handle=self.addon_handle) if self.defaultview_artists: xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_artists)
def browse_album(self): xbmcplugin.setContent(self.addon_handle, "songs") album = self.sp.album(self.albumid, market=self.usercountry) xbmcplugin.setProperty(self.addon_handle, 'FolderName', album["name"]) tracks = self.get_album_tracks(album) if album.get("album_type") == "compilation": self.add_track_listitems(tracks, True) else: self.add_track_listitems(tracks) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TRACKNUM) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_SONG_RATING) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_ARTIST) xbmcplugin.endOfDirectory(handle=self.addon_handle) if self.defaultview_songs: xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
def search_tracks(self): xbmcplugin.setContent(self.addon_handle, "songs") xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(134)) result = self.sp.search( q="track:%s" % self.trackid, type='track', limit=self.limit, offset=self.offset, market=self.usercountry) tracks = self.prepare_track_listitems(tracks=result["tracks"]["items"]) self.add_track_listitems(tracks, True) self.add_next_button(result['tracks']['total']) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.endOfDirectory(handle=self.addon_handle) if self.defaultview_songs: xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_songs)
def search_albums(self): xbmcplugin.setContent(self.addon_handle, "albums") xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(132)) result = self.sp.search( q="album:%s" % self.albumid, type='album', limit=self.limit, offset=self.offset, market=self.usercountry) albumids = [] for album in result['albums']['items']: albumids.append(album["id"]) albums = self.prepare_album_listitems(albumids) self.add_album_listitems(albums, True) self.add_next_button(result['albums']['total']) xbmcplugin.addSortMethod(self.addon_handle, xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.endOfDirectory(handle=self.addon_handle) if self.defaultview_albums: xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_albums)
def search_playlists(self): xbmcplugin.setContent(self.addon_handle, "files") result = self.sp.search( q=self.playlistid, type='playlist', limit=self.limit, offset=self.offset, market=self.usercountry) log_msg(result) xbmcplugin.setProperty(self.addon_handle, 'FolderName', xbmc.getLocalizedString(136)) playlists = self.prepare_playlist_listitems(result['playlists']['items']) self.add_playlist_listitems(playlists) self.add_next_button(result['playlists']['total']) xbmcplugin.endOfDirectory(handle=self.addon_handle) if self.defaultview_playlists: xbmc.executebuiltin('Container.SetViewMode(%s)' % self.defaultview_playlists)
def show_sport_selection(self): """Creates the KODI list items for the static sport selection""" self.utils.log('Sport selection') sports = self.constants.get_sports_list() for sport in sports: url = self.utils.build_url({'for': sport}) list_item = xbmcgui.ListItem(label=sports.get(sport).get('name')) list_item = self.item_helper.set_art( list_item=list_item, sport=sport) xbmcplugin.addDirectoryItem( handle=self.plugin_handle, url=url, listitem=list_item, isFolder=True) xbmcplugin.addSortMethod( handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_DATE) xbmcplugin.endOfDirectory(self.plugin_handle)
def channeltypes(params,url,category): logger.info("channelselector.channeltypes") lista = getchanneltypes() for item in lista: addfolder(item.title,item.channel,item.action,category=item.category,thumbnailname=item.thumbnail) if config.get_platform()=="kodi-krypton": import plugintools plugintools.set_view( plugintools.TV_SHOWS ) # Label (top-right)... import xbmcplugin xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category="" ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE ) xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True ) if config.get_setting("forceview")=="true": # Confluence - Thumbnail import xbmc xbmc.executebuiltin("Container.SetViewMode(500)")
def listchannels(params,url,category): logger.info("channelselector.listchannels") lista = filterchannels(category) for channel in lista: if config.is_xbmc() and (channel.type=="xbmc" or channel.type=="generic"): addfolder(channel.title , channel.channel , "mainlist" , channel.channel) elif config.get_platform()=="boxee" and channel.extra!="rtmp": addfolder(channel.title , channel.channel , "mainlist" , channel.channel) if config.get_platform()=="kodi-krypton": import plugintools plugintools.set_view( plugintools.TV_SHOWS ) # Label (top-right)... import xbmcplugin xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category ) xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE ) xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True ) if config.get_setting("forceview")=="true": # Confluence - Thumbnail import xbmc xbmc.executebuiltin("Container.SetViewMode(500)")
def show_listing(self, list_items, sort=None): listing = [] for title_item in list_items: list_item = xbmcgui.ListItem(label=title_item.title) url = self._url + '?' + urlencode(title_item.url_dictionary) list_item.setProperty('IsPlayable', str(title_item.is_playable)) if title_item.thumbnail is not None: list_item.setArt({'thumb': title_item.thumbnail}) list_item.setInfo('video', title_item.video_dictionary) listing.append((url, list_item, not title_item.is_playable)) xbmcplugin.addDirectoryItems(self._handle, listing, len(listing)) if sort is not None: kodi_sorts = {sortmethod.ALPHABET: xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE} kodi_sortmethod = kodi_sorts.get(sort) xbmcplugin.addSortMethod(self._handle, kodi_sortmethod) xbmcplugin.endOfDirectory(self._handle)
def _users(self): page = int(self.root.params['page']) users = media_entries('fave.getUsers', self.root.conn, _NO_OWNER, page = page) if page < users['pages']: params = {'do': _DO_FAVE_USERS, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) for u in users['items']: list_item = xbmcgui.ListItem(u'%s %s' % (u.info['last_name'], u.info['first_name'])) #p_key = 'photo_%d' % (max(map(lambda x: int(x.split('_')[1]), filter(lambda x: x.startswith('photo_'), m.info.keys()))),) #list_item.setArt({'thumb': m.info[p_key], 'icon': m.info[p_key]}) params = {'do': _DO_HOME, 'oid': u.id} url = self.root.url(**params) xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True) if page < users['pages']: params = {'do': _DO_FAVE_USERS, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) xbmcplugin.endOfDirectory(_addon_id)
def _groups(self): page = int(self.root.params['page']) links = media_entries('fave.getLinks', self.root.conn, _NO_OWNER, page = page) if page < links['pages']: params = {'do': _DO_FAVE_GROUPS, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) for l in links['items']: l_id = l.info['id'].split('_') if l_id[0] == '2': list_item = xbmcgui.ListItem(l.info['title']) p_key = 'photo_%d' % (max(map(lambda x: int(x.split('_')[1]), filter(lambda x: x.startswith('photo_'), l.info.keys()))),) list_item.setArt({'thumb': l.info[p_key], 'icon': l.info[p_key]}) params = {'do': _DO_HOME, 'oid': -int(l_id[-1])} url = self.root.url(**params) xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True) if page < links['pages']: params = {'do': _DO_FAVE_GROUPS, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) xbmcplugin.endOfDirectory(_addon_id)
def _photo_albums(self): page = int(self.root.params['page']) oid = self.root.params['oid'] kwargs = {'page': page, 'need_covers': 1, 'need_system': 1} albums = media_entries('photos.getAlbums', self.root.conn, oid, **kwargs) if page < albums['pages']: params = {'do': _DO_PHOTO_ALBUMS,'oid': oid,'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) for a in albums['items']: list_item = xbmcgui.ListItem(a.info['title']) list_item.setInfo('pictures', {'title': a.info['title']}) list_item.setArt({'thumb': a.info['thumb_src'], 'icon': a.info['thumb_src']}) params = {'do': _DO_PHOTO, 'oid': oid, 'album': a.id, 'page': 1} url = self.root.url(**params) xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True) if page < albums['pages']: params = {'do': _DO_PHOTO_ALBUMS,'oid': oid,'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) xbmcplugin.endOfDirectory(_addon_id) switch_view()
def _main_video_search(self): page = int(self.root.params['page']) self.root.add_folder(self.root.gui._string(400516), {'do': _DO_VIDEO_SEARCH, 'q':'none', 'page': 1}) history = get_search_history(_FILE_VIDEO_SEARCH_HISTORY) count = len(history) pages = int(ceil(count / float(_SETTINGS_PAGE_ITEMS))) if page < pages: params = {'do': _DO_MAIN_VIDEO_SEARCH, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) h_start = _SETTINGS_PAGE_ITEMS * (page -1) h_end = h_start + _SETTINGS_PAGE_ITEMS history = history[h_start:h_end] for h in history: query_hex = binascii.hexlify(pickle.dumps(h, -1)) list_item = xbmcgui.ListItem(h) params = {'do': _DO_VIDEO_SEARCH, 'q': query_hex, 'page': 1} url = self.root.url(**params) xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True) if page < pages: params = {'do': _DO_MAIN_VIDEO_SEARCH, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) xbmcplugin.endOfDirectory(_addon_id)
def _video(self): page = int(self.root.params['page']) oid = self.root.params['oid'] album = self.root.params.get('album', None) kwargs = {'page': page, 'extended': 1} if album: kwargs['album'] = album vids = media_entries('video.get', self.root.conn, oid, **kwargs) if page < vids['pages']: params = {'do': _DO_VIDEO,'oid': oid,'page': page + 1} if album: params['album'] = album self.root.add_folder(self.root.gui._string(400602), params) self.__create_video_list_(vids) if page < vids['pages']: params = {'do': _DO_VIDEO,'oid': oid,'page': page + 1} if album: params['album'] = album self.root.add_folder(self.root.gui._string(400602), params) xbmcplugin.endOfDirectory(_addon_id)
def _members(self): oid = self.root.params['oid'] page = int(self.root.params['page']) group = Group(oid, self.root.conn) members = group.members(page = page) if page < members['pages']: params = {'do': _DO_MEMBERS, 'oid': oid, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) for m in members['items']: list_item = xbmcgui.ListItem(u'%s %s' % (m.info['last_name'], m.info['first_name'])) p_key = 'photo_%d' % (max(map(lambda x: int(x.split('_')[1]), filter(lambda x: x.startswith('photo_'), m.info.keys()))),) list_item.setArt({'thumb': m.info[p_key], 'icon': m.info[p_key]}) params = {'do': _DO_HOME, 'oid': m.id} url = self.root.url(**params) xbmcplugin.addDirectoryItem(_addon_id, url, list_item, isFolder = True) if page < members['pages']: params = {'do': _DO_MEMBERS, 'oid': oid, 'page': page + 1} self.root.add_folder(self.root.gui._string(400602), params) xbmcplugin.endOfDirectory(_addon_id)
def build_no_search_results_available(self, build_url, action): """Builds the search results screen if no matches could be found Parameters ---------- 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 """ self.dialogs.show_no_search_results_notify() return xbmcplugin.endOfDirectory(self.plugin_handle)
def show_page(obj): for talk in obj.get_talks(): url = build_url({'mode': 'play', 'folder_name': talk.url}) li = xbmcgui.ListItem("%s - %s [COLOR=lime][%s][/COLOR][COLOR=cyan] Posted: %s[/COLOR]" % (talk.title, talk.speaker, talk.time, talk.posted)) li.setArt({'thumb': talk.thumb, 'icon': talk.thumb, 'fanart': talk.thumb}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) if obj.next_page: url = build_url({'mode': 'page', 'folder_name': obj.next_page}) li = xbmcgui.ListItem("[COLOR=yellow]Next Page %s[/COLOR]" % obj.page_number(obj.next_page)) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) if obj.last_page: url = build_url({'mode': 'page', 'folder_name': obj.last_page}) li = xbmcgui.ListItem("[COLOR=yellow]Last Page %s[/COLOR]" % obj.page_number(obj.last_page)) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) xbmcplugin.endOfDirectory(addon_handle)
def run(self, params): if params == {} or params == self.params(): return self.root() if 'list' in params.keys() and params['list'] != '': self.list(self.provider.list(params['list'])) if self.system is not None: self.provider.system(self.system, True) return self.endOfDirectory() if 'down' in params.keys(): self.force = True return self.download({'url': params['down'], 'title': params['title'], 'force': '1'}) if 'play' in params.keys(): return self.play({'url': params['play'], 'info': params}) if 'search-list' in params.keys(): return self.search_list() if 'search' in params.keys(): return self.do_search(params['search']) if 'search-remove' in params.keys(): return self.search_remove(params['search-remove']) if 'search-edit' in params.keys(): return self.search_edit(params['search-edit']) if self.run_custom: return self.run_custom(params)
def search_type(field): last_field = addon.getSetting('last_search_field').decode('utf-8') search_text = addon.getSetting('last_search_text').decode('utf-8') if last_field <> field or not search_text: addon.setSetting('last_search_field', field) keyboard = xbmc.Keyboard('', _T(30206)) keyboard.doModal() if keyboard.isConfirmed(): search_text = keyboard.getText() else: search_text = '' addon.setSetting('last_search_text', search_text) if search_text: searchresults = session.search(field, search_text) add_items(searchresults.artists, content=CONTENT_FOR_TYPE.get('files'), end=False) add_items(searchresults.albums, end=False) add_items(searchresults.playlists, end=False) add_items(searchresults.tracks, end=False) add_items(searchresults.videos, end=True) else: #xbmcplugin.setContent(plugin.handle, content='files') xbmcplugin.endOfDirectory(plugin.handle, succeeded=False, updateListing=False)
def run(): """Docstring""" # Gather the request info params = get_params() if 'action' in params: if params['action'] == "search": # If the action is 'search' use item information kodi provides to search for subtitles search(get_info(), get_languages(params, 0)) elif params['action'] == "manualsearch": # If the action is 'manualsearch' use user manually inserted string to search # for subtitles manual_search(params['searchstring'], get_languages(params, 0)) elif params['action'] == "download": # If the action is 'download' use the info provided to download the subtitle and give # the file path to kodi download(params) elif params['action'] == "download-addicted": # If the action is 'download' use the info provided to download the subtitle and give # the file path to kodi download_addicted(params) xbmcplugin.endOfDirectory(HANDLE)
def list_channels(): """show channels on the kodi list.""" playlist = utility.read_list(playlists_file) if not playlist: ok(ADDON.getLocalizedString(11005), ADDON.getLocalizedString(11006)) return None for channel in playlist: url = channel['url'].encode('utf-8') name = channel['display_name'].encode('utf-8') action_url = build_url({'mode': 'play', 'url': url, 'name': name}) item = xbmcgui.ListItem(name, iconImage='DefaultVideo.png') item.setInfo(type='Video', infoLabels={'Title': name}) xbmcplugin.addDirectoryItem(handle=HANDLE, url=action_url, listitem=item) xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=False)
def router(paramstring): params = dict(parse_qsl(paramstring[1:])) if params: if params['mode'] == 'play': play_item = xbmcgui.ListItem(path=params['link']) xbmcplugin.setResolvedUrl(__handle__, True, listitem=play_item) else: for stream in streams(): list_item = xbmcgui.ListItem(label=stream['name'], thumbnailImage=stream['thumb']) list_item.setProperty('fanart_image', stream['thumb']) list_item.setProperty('IsPlayable', 'true') url = '{0}?mode=play&link={1}'.format(__url__, stream['link']) xbmcplugin.addDirectoryItem(__handle__, url, list_item, isFolder=False) xbmcplugin.endOfDirectory(__handle__) # -------------------------------------------------------------------------------- # Main # --------------------------------------------------------------------------------
def router(paramstring): """Decides what to do based on script parameters""" check_settings() params = dict(parse_qsl(paramstring)) # Nothing to do yet with those if not params: # Demo channel list channels = map_channels(filter_channels(get_tv_channels())) xbmcplugin.addDirectoryItems(plugin_handle, channels, len(channels)) xbmcplugin.addSortMethod( plugin_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) xbmcplugin.endOfDirectory(plugin_handle) elif params['action'] == 'play': play_channel(params['channel']) elif params['action'] == 'get_user_id': get_user_id()
def main_menu(): addon_log('Hello World!') # print add-on version items = [language(30023), language(30015), language(30026), language(30036), language(30030)] for item in items: if item == language(30023): params = { 'action': 'list_events_by_date', 'schedule_type': 'all', 'filter_date': 'today' } elif item == language(30015): params = {'action': 'list_upcoming_days'} elif item == language(30026): params = { 'action': 'list_events', 'schedule_type': 'featured' } elif item == language(30036): params = {'action': 'search'} else: # auth details item = '[B]%s[/B]' % item params = {'action': 'show_auth_details'} add_item(item, params) xbmcplugin.endOfDirectory(_handle)
def list_upcoming_days(): event_dates = fsgo.get_event_dates() now = datetime.now() date_today = now.date() for date in event_dates: if date > date_today: title = date.strftime('%Y-%m-%d') params = { 'action': 'list_events_by_date', 'schedule_type': 'all', 'filter_date': date } add_item(title, params) xbmcplugin.endOfDirectory(_handle)
def LIST_TVSHOWS_CATS(): import tv as tvDB id_ = common.args.url if id_: asins = tvDB.lookupTVdb(id_, rvalue='asins', name='title', tbl='categories') epidb = tvDB.lookupTVdb('', name='asin', rvalue='asin, seasonasin', tbl='episodes', single=False) if not asins: return for asin in asins.split(','): seasonasin = None for epidata in epidb: if asin in str(epidata): seasonasin = epidata[1] break if not seasonasin: seasonasin = asin for seasondata in tvDB.loadTVSeasonsdb(seasonasin=seasonasin).fetchall(): ADD_SEASON_ITEM(seasondata, disptitle=True) common.SetView('seasons') else: for title in tvDB.lookupTVdb('', name='asins', tbl='categories', single=False): if title: common.addDir(title[0], 'listtv', 'LIST_TVSHOWS_CATS', title[0]) xbmcplugin.endOfDirectory(pluginhandle, updateListing=False)
def list_categories(): listing=[] list_item = xbmcgui.ListItem(label='??', thumbnailImage='') url='{0}?action=game_list'.format(_url) is_folder=True listing.append((url, list_item, is_folder)) list_item = xbmcgui.ListItem(label='Lyingman', thumbnailImage='') url='{0}?action=lyingman'.format(_url) 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 game_list(): 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)
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)
def list_prods(params): """ Arma la lista de producciones del menu principal """ # parámetros optativos items = int(addon.getSetting('itemsPerPage')) page = int(params.get('pag', '1')) orden = params.get('orden') if 'tvod' in params['url']: xbmcgui.Dialog().ok(translation(30033), translation(30034)) path = '{0}?perfil={1}&cant={2}&pag={3}'.format(params['url'], PID, items, page) if orden: path += '&orden={0}'.format(orden) prod_list = json_request(path) # lista todo menos temporadas, episodios y elementos de compilados for prod in prod_list['prods']: add_film_item(prod, params) if len(prod_list['prods']) == items: query = 'list_prods&url={0}&pag={1}'.format(quote(params['url']), page+1) if orden: query += '&orden={0}'.format(orden) add_directory_item(translation(30031), query, 'folder-movies.png') xbmcplugin.endOfDirectory(addon_handle)
def main(self): filters = self.eyny.list_filters() xbmcplugin.addDirectoryItem( handle=self.addon_handle, url=self._build_url('search'), listitem=xbmcgui.ListItem('Search'), isFolder=True) for category in filters['categories']: li = xbmcgui.ListItem(category['name']) xbmcplugin.addDirectoryItem( handle=self.addon_handle, url=self._build_url('list', cid=category['cid']), listitem=li, isFolder=True) for orderby in filters['mod']: li = xbmcgui.ListItem(orderby['name']) xbmcplugin.addDirectoryItem( handle=self.addon_handle, url=self._build_url('list', orderby=orderby['orderby']), listitem=li, isFolder=True) xbmcplugin.endOfDirectory(addon_handle)
def list_video(self, cid=None, page=1, orderby='channel'): try: result = self.eyny.list_videos(cid=cid, page=page, mod=orderby) except ValueError as e: xbmcgui.Dialog().ok( heading='Error', line1=unicode(e).encode('utf-8')) return self._add_video_items(result['videos'], result['current_url']) if page < int(result['last_page']): self._add_page_item( page+1, result['last_page'], 'list', orderby=orderby, cid=cid) xbmcplugin.endOfDirectory(self.addon_handle)
def search_video(self, search_string=None, page=1): if search_string is None: search_string = xbmcgui.Dialog().input( 'Search term', type=xbmcgui.INPUT_ALPHANUM) result = self.eyny.search_video(search_string, page=page) self._add_video_items(result['videos'], result['current_url']) if page < int(result['last_page']): self._add_page_item( page + 1, result['last_page'], 'search', search_string=search_string ) xbmcplugin.endOfDirectory(self.addon_handle)
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 listPage(page_id): nav = getNav() items = getPageItems(nav, page_id) if len(items) == 1: if 'path' in items[0].attrib: listPath(items[0].attrib['path']) return for item in items: url = '' if item.tag == 'item': url = common.build_url({'action': 'listPage', 'path': item.attrib['path']}) elif item.tag == 'section': url = common.build_url({'action': 'listPage', 'id': item.attrib['id']}) addDir(item.attrib['label'], url) if len(items) > 0: 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 INDEXT(): utils.addDir('[COLOR hotpink]BubbaPorn[/COLOR]','http://www.bubbaporn.com/page1.html',90,os.path.join(imgDir, 'bubba.png'),'') utils.addDir('[COLOR hotpink]Poldertube.nl[/COLOR] [COLOR orange](Dutch)[/COLOR]','http://www.poldertube.nl/pornofilms/nieuw',100,os.path.join(imgDir, 'poldertube.png'),0) utils.addDir('[COLOR hotpink]Milf.nl[/COLOR] [COLOR orange](Dutch)[/COLOR]','http://www.milf.nl/videos/nieuw',100,os.path.join(imgDir, 'milfnl.png'),1) utils.addDir('[COLOR hotpink]Sextube.nl[/COLOR] [COLOR orange](Dutch)[/COLOR]','http://www.sextube.nl/videos/nieuw',100,os.path.join(imgDir, 'sextube.png'),2) utils.addDir('[COLOR hotpink]TubePornClassic[/COLOR]','http://www.tubepornclassic.com/latest-updates/',360,os.path.join(imgDir, 'tubepornclassic.png'),'') utils.addDir('[COLOR hotpink]HClips[/COLOR]','http://www.hclips.com/latest-updates/',380,os.path.join(imgDir, 'hclips.png'),'') utils.addDir('[COLOR hotpink]PornHub[/COLOR]','http://www.pornhub.com/newest.html',390,os.path.join(imgDir, 'pornhub.png'),'') utils.addDir('[COLOR hotpink]Porndig[/COLOR] [COLOR white]Professional[/COLOR]','http://www.porndig.com',290,os.path.join(imgDir, 'porndig.png'),'') utils.addDir('[COLOR hotpink]Porndig[/COLOR] [COLOR white]Amateurs[/COLOR]','http://www.porndig.com',290,os.path.join(imgDir, 'porndig.png'),'') utils.addDir('[COLOR hotpink]AbsoluPorn[/COLOR]','http://www.absoluporn.com/en/',300,os.path.join(imgDir, 'absoluporn.gif'),'') utils.addDir('[COLOR hotpink]Anybunny[/COLOR]','http://anybunny.com/',320,os.path.join(imgDir, 'anybunny.png'),'') utils.addDir('[COLOR hotpink]SpankBang[/COLOR]','http://spankbang.com/new_videos/',440,os.path.join(imgDir, 'spankbang.png'),'') utils.addDir('[COLOR hotpink]Amateur Cool[/COLOR]','http://www.amateurcool.com/most-recent/',490,os.path.join(imgDir, 'amateurcool.png'),'') utils.addDir('[COLOR hotpink]Vporn[/COLOR]','https://www.vporn.com/newest/',500,os.path.join(imgDir, 'vporn.png'),'') utils.addDir('[COLOR hotpink]xHamster[/COLOR]','https://xhamster.com/',505,os.path.join(imgDir, 'xhamster.png'),'') xbmcplugin.endOfDirectory(utils.addon_handle, cacheToDisc=False)
def getDownloaderStatus(): for filename in os.listdir(ADDON.getSetting("config.plugins.iptvplayer.NaszaSciezka")): if filename.endswith('.wget'): myLog('Found: [%s]' % filename) list_item = xbmcgui.ListItem(label = filename[:-5]) url = get_url(action='wgetRead', fileName=filename) is_folder = False last_Lines = '' with open(os.path.join(ADDON.getSetting("config.plugins.iptvplayer.NaszaSciezka") , filename)) as f: last_Lines = f.readlines()[-5:] f.close() if ''.join(last_Lines).find('100%') > 0: list_item.setArt({'thumb': xbmc.translatePath('special://home/addons/plugin.video.IPTVplayer/resources/icons/done.png')}) else: list_item.setArt({'thumb': xbmc.translatePath('special://home/addons/plugin.video.IPTVplayer/resources/icons/progress.png')}) xbmcplugin.addDirectoryItem(ADDON_handle, url, list_item, is_folder) #last but not least delete all status files list_item = xbmcgui.ListItem(label = _(30434)) url = get_url(action='wgetDelete') is_folder = False list_item.setArt({'thumb': xbmc.translatePath('special://home/addons/plugin.video.IPTVplayer/resources/icons/delete.png')}) xbmcplugin.addDirectoryItem(ADDON_handle, url, list_item, is_folder) #closing directory xbmcplugin.endOfDirectory(ADDON_handle) return
def SelectHost(): for host in HostsList: if ADDON.getSetting(host[0]) == 'true': hostName = host[1].replace("https:",'').replace("http:",'').replace("/",'').replace("www.",'') hostImage = '%s/icons/%s.png' % (ADDON.getSetting("kodiIPTVpath"), host[0]) list_item = xbmcgui.ListItem(label = hostName) list_item.setArt({'thumb': hostImage,}) list_item.setInfo('video', {'title': hostName, 'genre': hostName}) url = get_url(action='startHost', host=host[0]) myLog(url) is_folder = True # Add our item to the Kodi virtual folder listing. xbmcplugin.addDirectoryItem(ADDON_handle, url, list_item, is_folder) # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(ADDON_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(ADDON_handle) return
def showSubCategories(url, category_id): """Show sub category Under Shows category, typically this is a list - All Shows - Drama - Subtitled Show - etc """ html = callServiceApi(url) main_nav = common.parseDOM(html, "div", attrs={'id': 'main_nav_desk'})[0] sub_categories = \ common.parseDOM(main_nav, 'li', attrs={'class': 'has_children'}) for sc in sub_categories: a = common.parseDOM(sc, 'a', attrs={'data-id': str(category_id)}) if len(a) > 0: ul = common.parseDOM(sc, 'ul', attrs={'class': 'menu_item'})[0] for li in common.parseDOM(ul, 'li'): url = common.parseDOM(li, 'a', ret='href')[0] name = common.parseDOM(li, 'a')[0] addDir(common.replaceHTMLCodes(name), url, Mode.SHOW_LIST, 'menu_logo.png') break xbmcplugin.endOfDirectory(thisPlugin)
def showMainMenu(): checkAccountChange() # cleanCookies(False) # if not logged in, ask to log in if isLoggedIn() == False: if (confirm(lang(57007), line1=lang(57008) % setting('emailAddress'))): (account, logged) = checkAccountChange(True) if logged == True: user = getUserInfo() showNotification(lang(57009) % user.get('FirstName', 'back to TFC'), title='') else: showNotification(lang(50205), title=lang(50204)) # if setting('displayMostLovedShows') == 'true': # addDir('Most Loved Shows', '/', 5, 'icon.png') if setting('displayWebsiteSections') == 'true': addDir('By Category', '/', 10, 'icon.png') else: showCategories() if setting('displayWebsiteSections') == 'true': sections = getWebsiteHomeSections() for s in sections: addDir(s['name'].title(), str(s['id']), 11, 'icon.png') if setting('displayMyAccountMenu') == 'true': addDir('My Account', '/', 12, 'icon.png') if setting('displayTools') == 'true': addDir('Tools', '/', 50, 'icon.png') xbmcplugin.endOfDirectory(thisPlugin)
def showCategories(): categories = lCacheFunction(getCategories) for c in categories: addDir(c['name'], str(c['id']), 1, 'icon.png') if setting('displayWebsiteSections') == 'true': xbmcplugin.endOfDirectory(thisPlugin)
def showTools(): addDir('Reload Catalog Cache', '/', 51, 'icon.png') addDir('Clean cookies file', '/', 52, 'icon.png') xbmcplugin.endOfDirectory(thisPlugin)
def showSubCategories(categoryId): subCategories = lCacheFunction(getSubCategories, categoryId) for s in subCategories: addDir(s['name'], str(s['id']), 2, 'menu_logo.png') xbmcplugin.endOfDirectory(thisPlugin)