def list_shows(genre_id): url = '/browse/shows/full/%s/alpha-asc/US/1000/1?format=json' % genre_id # url += '?pageSize=500' # url += '&pageNumber=1' # url += '&format=json' json_source = json_request(url) for show in json_source['Entries']: title = show['Title'] url = str(show['ID']) icon = show['ChannelArtTileLarge'] fanart = show['Images']['Img_TTU_1280x720'] if fanart == "": fanart = show['Images']['Img_1920x1080'] info = {'plot':show['Description'], 'genre':show['Genre'], 'year':show['ReleaseYear'], 'mpaa':show['Rating'], 'title':title, 'originaltitle':title, 'duration':show['DurationInSeconds'], 'mediatype': 'tvshow' } add_dir(title,url,102,icon,fanart,info,content_type='tvshows') xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
def list_movies(genre_id): url = '/browse/movies/full/%s/alpha-asc/US?format=json' % genre_id # url = '/browse/movies/full/all/alpha-asc/US' # url += '?pageSize=500' # url += '&pageNumber=1' # url += '&format=json' json_source = json_request(url) for movie in json_source['Entries']: title = movie['Title'] url = str(movie['ID']) icon = movie['ChannelArtTileLarge'] fanart = movie['Images']['Img_1920x1080'] info = { 'plot': movie['Description'], 'genre': movie['Genre'], 'year': movie['ReleaseYear'], 'mpaa': movie['Rating'], 'title': title, 'originaltitle': title, 'duration': movie['DurationInSeconds'], 'mediatype': 'movie' } add_stream(title, url, 'movies', icon, fanart, info) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
def endDir(handle, use_content_type, simple=False): if not simple: KodiUtil.addSorting(handle, use_content_type) else: xbmcplugin.addSortMethod( handle=handle, sortMethod=xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.endOfDirectory(handle)
def get_episodes(channel): url = '/channel/' + channel + '/playlists/all/US?format=json' json_source = json_request(url) for episode in json_source['Playlists'][0]['Items']: episode = episode['MediaInfo'] title = episode['Title'] id = str(episode['Id']) icon = episode['Images']['Img_460x460'] fanart = episode['Images']['Img_1920x1080'] info = { 'plot': episode['Description'], #'genre':episode['Genre'], 'year': episode['ReleaseYear'], 'mpaa': episode['Rating'], 'tvshowtitle': episode['ShowName'], 'title': title, 'originaltitle': title, 'duration': episode['Duration'], 'season': episode['Season'], 'episode': episode['Episode'], 'mediatype': 'episode' } add_stream(title, id, 'tvshows', icon, fanart, info) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_EPISODE)
def list_search(self): query = MxPlayerPlugin.get_user_input() if not query: return [] # Set plugin category. It is displayed in some skins as the name # of the current section. xbmcplugin.setPluginCategory(self.handle, 'Search/{}'.format(query)) data = self.make_request( self.MainUrl + 'search/result?query={}&userid={}&platform={}&content-languages={}' .format(urllib_parse.quote_plus(query), self.userid, self.platform, self.languages)) for item in data['sections']: if item.get('id') in ['shows', 'album']: self.add_directory_item( content_id=item['items'][0].get('id'), title=item['items'][0].get('title'), description=item['items'][0].get('title'), action='season', section_next=item.get('next'), item=item) elif item.get('id') in ['shorts', 'movie', 'music']: if item['items'][0].get('stream') is not None: self.add_video_item(item['items'][0]) # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE) xbmcplugin.endOfDirectory(self.handle)
def display(self): handle = _handle() items = [i for i in self.items if i] if not items and self.no_items_label: items.append( Item( label=_(self.no_items_label, _label=True), is_folder=False, )) for item in items: item.art['thumb'] = item.art.get('thumb') or self.thunb item.art['fanart'] = item.art.get('fanart') or 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)
def display(self): handle = _handle() items = [i for i in self.items if i] ep_sort = True last_show_name = '' 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 episode = item.info.get('episode') show_name = item.info.get('tvshowtitle') if not episode or not show_name or (last_show_name and show_name != last_show_name): ep_sort = False if not last_show_name: last_show_name = show_name 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) if not self.sort_methods: self.sort_methods = [ xbmcplugin.SORT_METHOD_EPISODE, xbmcplugin.SORT_METHOD_UNSORTED, xbmcplugin.SORT_METHOD_LABEL ] if not ep_sort: self.sort_methods.pop(0) for sort_method in self.sort_methods: xbmcplugin.addSortMethod(handle, sort_method) xbmcplugin.endOfDirectory(handle, succeeded=True, updateListing=self.updateListing, cacheToDisc=self.cacheToDisc) if self.show_news: process_news()
def album_view(album_id): xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_TRACKNUM) album = session.get_album(album_id) if album and album.numberOfVideos > 0: add_directory(_T(Msg.i30110), plugin.url_for(album_videos, album_id=album_id)) add_items(session.get_album_tracks(album_id), content=CONTENT_FOR_TYPE.get('tracks'))
def root(): list_items = [] for cat in TV.get_categories(): li = ListItem(cat.cat_name, offscreen=True) url = plugin.url_for(list_channels, cat_id=cat.cat_id) list_items.append((url, li, True)) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addDirectoryItems(plugin.handle, list_items) xbmcplugin.endOfDirectory(plugin.handle)
def process_tracks(context, url, tree=None): xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE) xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_DURATION) xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_SONG_RATING) xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_TRACKNUM) tree = get_xml(context, url, tree) if tree is None: return playlist = xbmc.PlayList(xbmc.PLAYLIST_MUSIC) playlist.clear() server = context.plex_network.get_server_from_url(url) content_counter = { 'photo': 0, 'track': 0, 'video': 0, } items = [] append_item = items.append if PY3: branches = tree.iter() else: branches = tree.getiterator() for branch in branches: tag = branch.tag.lower() item = Item(server, url, tree, branch) if tag == 'track': append_item(create_track_item(context, item)) elif tag == 'photo': # mixed content audio playlist append_item(create_photo_item(context, item)) elif tag == 'video': # mixed content audio playlist append_item(create_movie_item(context, item)) if isinstance(content_counter.get(tag), int): content_counter[tag] += 1 if items: content_type = 'songs' if context.settings.mixed_content_type() == 'majority': majority = max(content_counter, key=content_counter.get) if majority == 'photo': content_type = 'images' elif majority == 'video': content_type = 'movies' xbmcplugin.setContent(get_handle(), content_type) xbmcplugin.addDirectoryItems(get_handle(), items, len(items)) xbmcplugin.endOfDirectory(get_handle(), cacheToDisc=context.settings.cache_directory())
def list_genre(id): url = '/genres/%s/all/US?format=json' % id json_source = json_request(url) for genre in json_source['Items']: title = genre['Name'] add_dir(title, id, 100, ICON, genre_id=genre['ID']) # add_dir(name, id, mode, icon, fanart=None, info=None, genre_id=None) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
def favouriteUsers(): xbmcplugin.addSortMethod(pluginhandle, xbmcplugin.SORT_METHOD_LABEL) if xbmcvfs.exists(channelFavsFile): with open(channelFavsFile, 'r') as fh: content = fh.read() match = re.compile('###USER###=(.+?)###THUMB###=(.*?)###END###', re.DOTALL).findall(content) for user, thumb in match: addUserFavDir(user, 'owner:{0}'.format(user), 'sortVideos1', thumb) xbmcplugin.setContent(pluginhandle, "addons") if force_mode: xbmc.executebuiltin('Container.SetViewMode({0})'.format(menu_mode)) xbmcplugin.endOfDirectory(pluginhandle)
def process_artists(context, url, tree=None): """ Process artist XML and display data @input: url of XML page, or existing tree of XML page @return: nothing """ xbmcplugin.setContent(get_handle(), 'artists') xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_ARTIST_IGNORE_THE) xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_LASTPLAYED) xbmcplugin.addSortMethod(get_handle(), xbmcplugin.SORT_METHOD_VIDEO_YEAR) # Get the URL and server name. Get the XML and parse tree = get_xml(context, url, tree) if tree is None: return server = context.plex_network.get_server_from_url(url) items = [] append_item = items.append if PY3: artists = tree.iter('Directory') else: artists = tree.getiterator('Directory') for artist in artists: item = Item(server, url, tree, artist) append_item(create_artist_item(context, item)) if items: xbmcplugin.addDirectoryItems(get_handle(), items, len(items)) xbmcplugin.endOfDirectory(get_handle(), cacheToDisc=context.settings.cache_directory())
def run(self): params=self.getParams() try: url=urllib.parse.unquote(params["url"]) except: url=None try: name=urllib.parse.unquote(params["name"]) except: name=None try: mode=int(params["mode"]) except: mode=None log("Mode: "+str(mode)) log("URL : "+str(url)) log("Name: "+str(name)) if mode==None: self.buildItemMenu() if mode==1: self.buildItemMenu(url) if mode==2: self.buildItemMenu(search=True) if mode==3: self.searchItem(url) if mode==7: self.genSTRMS(name, url) if mode==8: self.playLater(name, url) if mode==9: self.playVideo(name, url) xbmcplugin.setContent(int(self.sysARG[1]) , CONTENT_TYPE) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.endOfDirectory(int(self.sysARG[1]), cacheToDisc=False)
def browseSeries(self, seriesid): log('browseSeries') progs = self.pyHDHR.getFilteredRecordedPrograms(grouptype=1, groupby=seriesid) if not progs: return for prog in progs: title = prog.getTitle() eptitle = prog.getEpisodeTitle() starttime = (datetime.datetime.fromtimestamp(float(prog.getStartTime()))) stime = starttime.strftime('%I:%M %p').lstrip('0') if len(eptitle) > 0: label = '%s: %s - %s'%(stime,title,eptitle) else: label = '%s: %s'%(stime,title) label, liz = self.buildRecordListItem(prog, label) self.addLink(label, (playVOD,tunerkey,prog.getPlayURL()), listitem=liz) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_DATEADDED)
def run(self): ROUTER.run() xbmcplugin.setContent(ROUTER.handle ,CONTENT_TYPE) xbmcplugin.addSortMethod(ROUTER.handle ,xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(ROUTER.handle ,xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(ROUTER.handle ,xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(ROUTER.handle ,xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.endOfDirectory(ROUTER.handle ,cacheToDisc=DISC_CACHE)
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 list_live(): live_data = mytv.get_live_events() list_items = [] for day, events in live_data.items(): for event in events: if len(event["channel_list"]) == 0: continue event_time = time_from_zone(datetime.utcfromtimestamp(int(event["start"])).strftime("%c"), "%Y-%m-%d %H:%M") title = "[{0}] {1}".format(event_time, event["title"]) li = ListItem(title, offscreen=True) li.setProperty("IsPlayable", "true") li.setInfo(type="Video", infoLabels={"Title": title, "mediatype": "video"}) url = plugin.url_for(event_resolve, title=event["title"].encode("utf-8")) list_items.append((url, li, False)) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addDirectoryItems(plugin.handle, list_items) xbmcplugin.setContent(plugin.handle, "videos") xbmcplugin.endOfDirectory(plugin.handle)
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 list_main(self): # Set plugin category. It is displayed in some skins as the name # of the current section. xbmcplugin.setPluginCategory(self.handle, 'main') for category in MxPlayerPlugin.MAIN_CATEGORIES['Main']: self.add_directory_item(content_id=category[0], title=category[1], description=category[1], action='sections', section_next='first', item=None) self.add_search_item() # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(self.handle)
def list_channels(cat_id=None): list_items = [] for channel in TV.get_channels_by_category(cat_id): title = "{0} - {1}".format(channel.country, channel.channel_name.rstrip(".,-")) image = TV.image_url(channel.img) li = ListItem(title, offscreen=True) li.setProperty("IsPlayable", "true") li.setArt({"thumb": image, "icon": image}) li.setInfo(type="Video", infoLabels={ "Title": title, "mediatype": "video" }) url = plugin.url_for(play, pk_id=channel.pk_id) list_items.append((url, li, False)) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addDirectoryItems(plugin.handle, list_items) xbmcplugin.setContent(plugin.handle, "videos") xbmcplugin.endOfDirectory(plugin.handle)
def run(customer, host='telezueri.ch'): """ Run the plugin. """ params = get_params() try: url = unquote_plus(params['url']) except Exception: url = None try: name = unquote_plus(params['name']) except Exception: name = None try: mode = int(params['mode']) except Exception: mode = None try: group = unquote_plus(params['group']) except Exception: group = None try: kaltura_id = unquote_plus(params['kaltura_id']) except Exception: kaltura_id = None log('Mode: %s, URL: %s, Name: %s, Group: %s, Kaltura ID: %s' % (str(mode), str(url), str(name), str(group), str(kaltura_id)), debug=True) if mode is None: AZMedien(customer, host).build_main_menu() elif mode == 10: AZMedien(customer, host).build_all_shows_menu() elif mode == 11: AZMedien(customer, host).build_show_menu('/news') elif mode == 12: AZMedien(customer, host).build_categories_menu() elif mode == 20: AZMedien(customer, host).build_show_menu(name, select_group=group) elif mode == 21: AZMedien(customer, host).build_show_menu(name, playlist=True) elif mode == 50: AZMedien(customer, host).play_video(name, kaltura_id) xbmcplugin.setContent(int(sys.argv[1]), CONTENT_TYPE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=True)
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 list_live(): if current_time - live_data_time > 30 * 60: live_data = new_channels.get_live_list() with io.open(live_list_file, "w", encoding="utf-8") as f: f.write( json.dumps(live_data, indent=2, sort_keys=True, ensure_ascii=False)) addon.setSetting("live_data_time36", str(int(time.time()))) else: with io.open(live_list_file, "r", encoding="utf-8") as f: live_data = json.loads(f.read()) list_items = [] for day, events in live_data.items(): for event in events: if len(event["channel_list"]) == 0: continue event_time = time_from_zone( datetime.utcfromtimestamp(int(event["start"])).strftime("%c"), "%Y-%m-%d %H:%M") title = "[{0}] {1}".format(event_time, event["title"]) li = ListItem(title, offscreen=True) li.setProperty("IsPlayable", "true") li.setInfo(type="Video", infoLabels={ "Title": title, "mediatype": "video" }) li.setContentLookup(False) url = plugin.url_for(event_resolve, title=event["title"].encode("utf-8")) list_items.append((url, li, False)) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addDirectoryItems(plugin.handle, list_items) xbmcplugin.setContent(plugin.handle, "videos") xbmcplugin.endOfDirectory(plugin.handle)
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_sections(self, sec_id, sec_next): # Set plugin category. It is displayed in some skins as the name # of the current section. xbmcplugin.setPluginCategory(self.handle, 'sections') data = self.make_request( self.MainUrl + 'home/tab/{}?{}&userid={}&platform={}&content-languages={}'.format( sec_id, sec_next, self.userid, self.platform, self.languages)) #web_pdb.set_trace() for item in data['sections']: self.add_directory_item(title=item.get('name'), content_id=item.get('id'), description=item.get('name'), section_next=item.get('next'), action='folder') if data['next'] is not None: data = self.make_request( self.MainUrl + 'home/tab/{}?{}&userid={}&platform={}&content-languages={}'. format(sec_id, data['next'], self.userid, self.platform, self.languages)) #web_pdb.set_trace() for item in data['sections']: self.add_directory_item(title=item.get('name'), content_id=item.get('id'), description=item.get('name'), section_next=item.get('next'), action='folder') self.add_next_page_and_search_item(item=data, original_title='sections', action='sections') # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(self.handle)
def list_show(self, show_id, title, show_next): # Set plugin category. It is displayed in some skins as the name # of the current section. xbmcplugin.setPluginCategory(self.handle, title) #web_pdb.set_trace() data = self.make_request( self.MainUrl + 'detail/tab/tvshowepisodes?{}&type=season&id={}&userid={}&platform={}&content-languages={}' .format(show_next, show_id, self.userid, self.platform, self.languages)) for shows in data['items']: self.add_video_item(shows) self.add_next_page_and_search_item(item=data, original_title=title, action='show') # Add a sort method for the virtual folder items (alphabetically, ignore articles) xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_NONE) # Finish creating a virtual folder. xbmcplugin.endOfDirectory(self.handle)
def channel_list(): url = plugin.args["url"][0] list_items = [] user_agent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" s = requests.Session() r = s.get(url, headers={"User-Agent": user_agent}, timeout=5, verify=False) r.raise_for_status() channels = r.json() for c in channels: if c["type"] == "public": li = xbmcgui.ListItem(c["name"]) li.setProperty("IsPlayable", "true") li.setInfo(type="Video", infoLabels={ "Title": c["name"], "mediatype": "video" }) url = "plugin://script.tvbus.player/?url={0}".format(c["address"]) list_items.append((url, li, False)) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addDirectoryItems(plugin.handle, list_items) xbmcplugin.setContent(plugin.handle, "videos") xbmcplugin.endOfDirectory(plugin.handle)
def addDir(name, handleID, url, mode, info=None, art=None, menu=None): global CONTENT_TYPE, ADDON_URL log('Adding directory %s' % name) directory = xbmcgui.ListItem(name) directory.setProperty('IsPlayable', 'false') if info is None: directory.setInfo(type='Video', infoLabels={ 'mediatype': 'videos', 'title': name }) else: if 'mediatype' in info: CONTENT_TYPE = '%ss' % info['mediatype'] directory.setInfo(type='Video', infoLabels=info) if art is None: directory.setArt({'thumb': ICON, 'fanart': FANART}) else: directory.setArt(art) if menu is not None: directory.addContextMenuItems(menu) 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)) log('Directory %s URL: %s' % (name, url)) xbmcplugin.addDirectoryItem(handle=handleID, url=url, listitem=directory, isFolder=True) xbmcplugin.addSortMethod( handle=handleID, sortMethod=xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE)
def run(self): params=self.getParams() try: url = urllib.parse.unquote_plus(params["url"]) except: url = None try: name = urllib.parse.unquote_plus(params["name"]) except: name = None try: mode = int(params["mode"]) except: mode = None log("Mode: %s, Name: %s, URL : %s"%(mode,name,url)) if mode==None: self.mainMenu() elif mode == 0: self.buildLive() elif mode == 1: self.buildLineup(url) elif mode == 2: self.buildRecordings() elif mode == 8: self.search(name) elif mode == 9: self.playVideo(name, url) xbmcplugin.setContent(int(self.sysARG[1]) , CONTENT_TYPE) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_NONE) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(int(self.sysARG[1]) , xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.endOfDirectory(int(self.sysARG[1]), cacheToDisc=DISC_CACHE)
def helper_kodi_directory_setup(kodi_directory, content_type): kodi_directory.set_content(content_type) for method in _kodi_directory_methods: xbmcplugin.addSortMethod(handle=config.app.handle, sortMethod=method)