def view(items, update_listing=False, urls=None): if urls is None: urls = [plugin.url_for_path(item.url) for item in items] total = len(items) for item, url in zip(items, urls): if not getattr(item, 'available', True): continue title = item.title if getattr(item, 'episode', None): title += " " + item.episode li = ListItem(title) playable = plugin.route_for(url) == play li.setProperty('isplayable', str(playable)) li.setArt({ 'thumb': getattr(item, 'thumb', ''), 'fanart': getattr(item, 'fanart', ''), }) info = {'title': title} if hasattr(item, 'description'): info['plot'] = item.description if hasattr(item, 'category') and item.category: info['genre'] = item.category.title if hasattr(item, 'legal_age'): info['mpaa'] = item.legal_age if hasattr(item, 'aired'): info['aired'] = item.aired.strftime('%Y-%m-%d') li.setInfo('video', info) if playable: li.addStreamInfo('video', {'codec': 'h264', 'width': 1280, 'height': 720, 'duration': item.duration}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, url, li, not playable, total) endOfDirectory(plugin.handle, updateListing=update_listing)
def view(items, update_listing=False, urls=None): if urls is None: urls = [plugin.url_for_path(item.url) for item in items] total = len(items) for item, url in zip(items, urls): if not getattr(item, 'available', True): continue title = item.title if getattr(item, 'episode', None): title += " " + item.episode li = ListItem(title, thumbnailImage=getattr(item, 'thumb', '')) playable = plugin.route_for(url) == play li.setProperty('isplayable', str(playable)) if hasattr(item, 'fanart'): li.setProperty('fanart_image', item.fanart) if playable: info = { 'title': title, 'plot': item.description, 'mpaa': item.legal_age, } if item.category: info['genre'] = item.category.title if item.aired: info['aired'] = item.aired.strftime('%Y-%m-%d') li.setInfo('video', info) li.addStreamInfo('video', {'codec': 'h264', 'width': 1280, 'height': 720, 'duration': item.duration}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, url, li, not playable, total) endOfDirectory(plugin.handle, updateListing=update_listing)
def view(items, update_listing=False, urls=None): total = len(items) for item, url in zip(items, urls): is_episode = isinstance(item, podcastapi.Episode) title = getattr(item, 'title') info = { 'title': title } li = ListItem(title) li.setLabel2(item.subtitle) li.setIconImage(item.thumb or '') li.setArt({ 'thumb': item.logo or '' }) if is_episode: li.setProperty('mimetype', 'audio/mpeg') li.setProperty('isplayable', 'true') li.addStreamInfo('audio', { 'codec': 'mp3', 'channels': 2 }) info['duration'] = item.duration info['year'] = item.year li.setInfo('music', info) addDirectoryItem(plugin.handle, url, li, not is_episode, total) endOfDirectory(plugin.handle, updateListing=update_listing)
def videoInfoToListItem(videoInfos): result = [] for info in videoInfos: liz = ListItem(label=info['title']) infolabels = {"plot": info["description"]} liz.setInfo(type="video", infoLabels=infolabels) liz.setProperty("videoid", info['id']) liz.setProperty("url", info['files'][next(iter(info['files']))]) liz.setProperty('IsPlayable', 'true') liz.setArt({ 'thumb': constructResourceURL(info['thumb']), 'fanart': constructResourceURL(info['thumb']), #"poster": remoteConfig['peertube']['serverRoot'] + info['thumb'] }) #liz.setProperty("type","playlist") video_info = { 'codec': 'avc1', 'aspect': 1.78, 'width': 1920, 'height': 1080 } liz.addStreamInfo('video', video_info) audio_info = {'codec': 'aac', 'language': 'zh-hk', 'channels': 2} liz.addStreamInfo('audio', audio_info) result.append(liz) #liz.setProperty('IsPlayable', 'true') #cm = [] #cm.append(("Info", 'XBMC.Action(Info)')) #liz.addContextMenuItems(cm, replaceItems=False) return result
def _generate_listitem(title_item): """ Generate a ListItem from a TitleItem """ from xbmcgui import ListItem # Three options: # - item is a virtual directory/folder (not playable, path) # - item is a playable file (playable, path) # - item is non-actionable item (not playable, no path) is_folder = bool(not title_item.is_playable and title_item.path) is_playable = bool(title_item.is_playable and title_item.path) list_item = ListItem(label=title_item.title, path=title_item.path) if title_item.prop_dict: list_item.setProperties(title_item.prop_dict) list_item.setProperty(key='IsPlayable', value='true' if is_playable else 'false') list_item.setIsFolder(is_folder) if title_item.art_dict: list_item.setArt(title_item.art_dict) if title_item.info_dict: # type is one of: video, music, pictures, game list_item.setInfo(type='video', infoLabels=title_item.info_dict) if title_item.stream_dict: # type is one of: video, audio, subtitle list_item.addStreamInfo('video', title_item.stream_dict) if title_item.context_menu: list_item.addContextMenuItems(title_item.context_menu) return list_item
def new_folder_item(self, item_name, func, iconURL="", description="", item_val=None, label2=""): li = ListItem(label=item_name) li.setIsFolder(True) li.setProperty('IsPlayable', 'True') # This is just so that the left hand plot shows up in Kodi li.setInfo('video', {'plot': description}) li.addStreamInfo('video', {'duration': label2, 'plot': description}) li.setArt({ 'icon': iconURL, 'poster': iconURL, 'thumb': iconURL, 'banner': iconURL }) addDirectoryItem(self.h, self.plugin.url_for(func, item_val=item_val), listitem=li, isFolder=True)
def show_movie(movie): kids = _get_kids_mode() try: _vtmGo = VtmGo(kids=kids) movie_obj = _vtmGo.get_movie(movie) except Exception as ex: notification(message=str(ex)) raise listitem = ListItem(movie_obj.name, offscreen=True) listitem.setPath(plugin.url_for(play_movie, movie=movie)) listitem.setArt({ 'thumb': movie_obj.cover, 'fanart': movie_obj.cover, }) listitem.setInfo( 'video', { 'title': movie_obj.name, 'plot': _format_plot(movie_obj), 'duration': movie_obj.duration, 'year': movie_obj.year, 'mediatype': movie_obj.mediatype, 'aired': movie_obj.aired, }) listitem.addStreamInfo('video', { 'duration': movie_obj.duration, }) listitem.setProperty('IsPlayable', 'true') listitem.setContentLookup(False) Dialog().info(listitem)
def build_followed_replay_user(user): any_replays = False h = plugin.handle setContent(h, "videos") f = dq.replays(user, xbmcaddon.Addon().getSetting("user")) for u in f: title = u[0] length = u[1] thumb = u[2] playback_url = u[3] li = ListItem(title, iconImage=thumb) li.setProperty('IsPlayable', 'True') li.setInfo("video", {'mediatype': 'video', 'duration': length}) li.addStreamInfo('video', {'duration': length}) li.setArt({'icon': thumb}) li.setArt({'poster': thumb}) li.setArt({'thumb': thumb}) li.setArt({'banner': thumb}) addDirectoryItem(h, playback_url, listitem=li, isFolder=False) any_replays = True if not any_replays: li = ListItem("** NO REPLAYS FOUND **", iconImage="") li.setProperty('IsPlayable', 'False') addDirectoryItem(h, "", listitem=li, isFolder=False) endOfDirectory(h)
def build_all_livestreams(): any_replays = False h = plugin.handle setContent(h, "videos") f = dq.all_live_streams() for u in f: title = u[0] playback_url = u[1] thumb = u[2] user = u[3] li = ListItem(user + ": " + title, iconImage=thumb) #li.setLabel(title) #li.setLabel2(user) li.setProperty('IsPlayable', 'True') li.setInfo("video", {'mediatype': 'video', 'duration': 0}) li.addStreamInfo('video', {'duration': 0}) li.setArt({'icon': thumb}) li.setArt({'poster': thumb}) li.setArt({'thumb': thumb}) li.setArt({'banner': thumb}) addDirectoryItem(h, playback_url, listitem=li, isFolder=False) any_replays = True if not any_replays: li = ListItem("** NO LIVE STREAMS FOUND **", iconImage="") li.setProperty('IsPlayable', 'False') addDirectoryItem(h, "", listitem=li, isFolder=False) endOfDirectory(h)
def new_video_item(self, displayName, title, playURL, thumbURL, duration, description=""): if displayName is not None: str = displayName + ": " + title else: str = title li = ListItem(label=str, path=playURL) li.setProperty('IsPlayable', 'True') li.addStreamInfo('video', {'duration': duration, 'plot': description}) li.setArt({ 'icon': thumbURL, 'poster': thumbURL, 'thumb': thumbURL, 'banner': thumbURL }) #li.setInfo('video', { 'plot': 'Left hand desc' }) addDirectoryItem(self.h, playURL, listitem=li, isFolder=False)
def make_playable(self, playablename, thumbnail, duration, url): li = ListItem(playablename, iconImage='DefaultTVShows.png') li.setProperty('IsPlayable', 'True') li.setInfo("video", {'mediatype': 'video', 'duration': duration}) li.addStreamInfo('video', {'duration': duration}) li.setArt({'icon': thumbnail}) li.setArt({'poster': thumbnail}) li.setArt({'thumb': thumbnail}) li.setArt({'banner': thumbnail}) addDirectoryItem(self.handle, url=url, listitem=li)
def root(): li = ListItem("Fatstone Live") li.setProperty('mimetype', "application/vnd.apple.mpegurl") li.setProperty('isplayable', 'true') li.setArt({'thumb': "http://dump.no/files/ea040880feb3/fatstonethumb.png"}) li.setInfo('video', {'title': "Fatstone Live"}) li.addStreamInfo('video', {'codec': 'h264', 'width': 1024, 'height': 576}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, "http://usa1.cdn.trippelm.tv/fs/live/ngrp:live_all/manifest.m3u8", li, False) endOfDirectory(plugin.handle)
def live(): import nrktv_mobile as nrk_tv for ch in nrk_tv.channels(): li = ListItem(ch.title, thumbnailImage=ch.thumb) li.setProperty('mimetype', "application/vnd.apple.mpegurl") li.setProperty('isplayable', 'true') li.setProperty('fanart_image', ch.fanart) li.setInfo('video', {'title': ch.title}) li.addStreamInfo('video', {'codec': 'h264', 'width': 1280, 'height': 720}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, ch.media_url, li, False) add_radio_channels() endOfDirectory(plugin.handle)
def build_video_item(name,thumb,videoid,info,video_info,audio_info): liz=ListItem(name) cm = [] cm.append(("Info", 'XBMC.Action(Info)')) thumb = thumb if thumb else xbmcaddon.Addon().getAddonInfo("icon") liz.setProperty("type", "youtube_video") liz.setProperty("videoid",videoid) liz.setArt({'thumb': thumb, 'fanart': xbmcaddon.Addon().getAddonInfo("fanart"), "poster": thumb}) liz.setInfo(type="Video", infoLabels=info) liz.addStreamInfo('video', video_info) liz.addStreamInfo('audio', audio_info) liz.setProperty('IsPlayable', 'true') liz.addContextMenuItems(cm, replaceItems=False) return liz
def build_video_item(name,thumb,videoid,info,video_info,audio_info): liz=ListItem(name) cm = [] cm.append(("Info", 'XBMC.Action(Info)')) thumb = thumb if thumb else xbmcaddon.Addon().getAddonInfo("icon") liz.setProperty("type", "youtube_video") liz.setProperty("videoid",videoid) liz.setArt({'thumb': thumb, 'fanart': xbmcaddon.Addon().getAddonInfo("fanart"), "poster": thumb}) liz.setInfo(type="Video", infoLabels=info) liz.addStreamInfo('video', video_info) liz.addStreamInfo('audio', audio_info) liz.setProperty('IsPlayable', 'true') liz.addContextMenuItems(cm, replaceItems=False) return liz
def view(titles, urls, thumbs=repeat(''), bgs=repeat(''), descr=repeat(''), update_listing=False): total = len(titles) for title, url, descr, thumb, bg in zip(titles, urls, descr, thumbs, bgs): descr = descr() if callable(descr) else descr thumb = thumb() if callable(thumb) else thumb bg = bg() if callable(bg) else bg li = ListItem(title, thumbnailImage=thumb) playable = plugin.route_for(url) == play li.setProperty('isplayable', str(playable)) li.setProperty('fanart_image', bg) if playable: li.setInfo('video', {'title':title, 'plot':descr}) li.addStreamInfo('video', {'codec':'h264', 'width':1280, 'height':720}) li.addStreamInfo('audio', {'codec':'aac', 'channels':2}) addDirectoryItem(plugin.handle, plugin.make_url(url), li, not playable, total) endOfDirectory(plugin.handle, updateListing=update_listing)
def live(): for ch in nrktv.channels(): li = ListItem(ch.title, thumbnailImage=ch.thumb) li.setProperty('mimetype', "application/vnd.apple.mpegurl") li.setProperty('isplayable', 'true') li.setProperty('fanart_image', ch.fanart) li.setInfo('video', {'title': ch.title}) li.addStreamInfo('video', {'codec': 'h264', 'width': 1280, 'height': 720}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, ch.media_url, li, False) url = "https://nrktegnsprak-lh.akamaihd.net/i/nrktegnsprak_0@111177/master.m3u8" li = ListItem("Tegnspråk", thumbnailImage="http://gfx.nrk.no/R4LFuTHBHWPMmv1dkqvPGQY4-ZZTKdNKAFPg_LHhoEFA") li.setProperty('isplayable', 'true') addDirectoryItem(plugin.handle, url, li, False) add_radio_channels() endOfDirectory(plugin.handle)
def live(): for ch in nrktv.channels(): li = ListItem(ch.title) li.setProperty('mimetype', "application/vnd.apple.mpegurl") li.setProperty('isplayable', 'true') li.setArt({'thumb': ch.thumb, 'fanart': ch.fanart}) li.setInfo('video', {'title': ch.title}) li.addStreamInfo('video', {'codec': 'h264', 'width': 1280, 'height': 720}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, enrichForForeignViewers(ch.media_url), li, False) url = "https://nrktegnsprak-lh.akamaihd.net/i/nrktegnsprak_0@111177/master.m3u8" li = ListItem("Tegnspråk") li.setArt({'thumb': "http://gfx.nrk.no/R4LFuTHBHWPMmv1dkqvPGQY4-ZZTKdNKAFPg_LHhoEFA"}) li.setProperty('isplayable', 'true') addDirectoryItem(plugin.handle, enrichForForeignViewers(url), li, False) add_radio_channels() endOfDirectory(plugin.handle)
def show_room(day, year, room): exp = './day[@index="{}"]/room[@name="{}"]/event'.format(day, room) root = fetch_xml(year) for event in root.findall(exp): if not contains_videos(event.findall('./links/link')): continue event_id = event.attrib['id'] title = event.find('title').text track = event.find('track').text subtitle = event.find('subtitle').text person_items = event.find('./persons/person') persons = [p.text for p in person_items] if person_items is not None else [] abstract = event.find('abstract').text duration = event.find('duration').text or '0:0' if abstract: abstract = abstract.replace('<p>', '').replace('</p>', '') item = ListItem(title) item.setProperty('IsPlayable', 'true') item.setInfo( 'video', { 'cast': persons, 'genre': track, 'plot': abstract, 'tagline': subtitle, 'title': title, }) # duration is formatted as 01:30 hour, minute = duration.split(':') seconds = timedelta(hours=int(hour), minutes=int(minute)).total_seconds() item.addStreamInfo('video', {'duration': seconds}) url = plugin.url_for(show_event, year=year, event_id=event_id) addDirectoryItem(plugin.handle, url, item, False) setContent(plugin.handle, 'videos') endOfDirectory(plugin.handle)
def view(titles, urls, thumbs=repeat(''), bgs=repeat(''), descr=repeat(''), update_listing=False): total = len(titles) for title, url, descr, thumb, bg in zip(titles, urls, descr, thumbs, bgs): descr = descr() if callable(descr) else descr thumb = thumb() if callable(thumb) else thumb bg = bg() if callable(bg) else bg li = ListItem(title, thumbnailImage=thumb) playable = plugin.route_for(url) == play li.setProperty('isplayable', str(playable)) li.setProperty('fanart_image', bg) if playable: li.setInfo('video', {'title':title, 'plot':descr}) li.addStreamInfo('video', {'codec':'h264', 'width':1280, 'height':720}) li.addStreamInfo('audio', {'codec':'aac', 'channels':2}) commands = [] search_url = plugin.make_url( "/searchfor/%s" % title.encode('utf-8') ) runner = "XBMC.ActivateWindow(Video," + search_url + ",return)" commands.append(( str("Search NRK..."), runner)) li.addContextMenuItems( commands ) addDirectoryItem(plugin.handle, plugin.make_url(url), li, not playable, total) endOfDirectory(plugin.handle, updateListing=update_listing)
def convert_pkc_to_listitem(pkc_listitem): """ Insert a PKCListItem() and you will receive a valid XBMC listitem """ data = pkc_listitem.data listitem = ListItem(label=data.get('label'), label2=data.get('label2'), path=data.get('path')) if data['info']: listitem.setInfo(**data['info']) for stream in data['stream_info']: # Kodi documentation up to date? CAREFUL as type= seems to be cType= # and values= seems to be dictionary= listitem.addStreamInfo(**stream) if data['art']: listitem.setArt(data['art']) for key, value in data['property'].iteritems(): listitem.setProperty(key, value) if data['subtitles']: listitem.setSubtitles(data['subtitles']) return listitem
def live(): for ch in nrktv.channels(): li = ListItem(ch.title) li.setProperty('mimetype', "application/vnd.apple.mpegurl") li.setProperty('isplayable', 'true') li.setArt({'thumb': ch.thumb, 'fanart': ch.fanart}) li.setInfo('video', {'title': ch.title}) li.addStreamInfo('video', { 'codec': 'h264', 'width': 1280, 'height': 720 }) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem( plugin.handle, plugin.url_for(live_resolve, ch.manifest.split('/')[-1]), li, False) for rd in nrktv.radios(): li = ListItem(rd.title) li.setProperty('mimetype', "audio/mpeg") li.setProperty('isplayable', 'true') li.setArt({'thumb': rd.thumb, 'fanart': rd.fanart}) li.setInfo('video', {'title': ch.title}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem( plugin.handle, plugin.url_for(live_resolve, rd.manifest.split('/')[-1]), li, False) endOfDirectory(plugin.handle)
def convert_PKC_to_listitem(PKC_listitem): """ Insert a PKC_listitem and you will receive a valid XBMC listitem """ data = PKC_listitem.data log.debug('data is: %s' % data) listitem = ListItem(label=data.get('label'), label2=data.get('label2'), path=data.get('path')) if data['info']: listitem.setInfo(**data['info']) for stream in data['stream_info']: # Kodi documentation up to date? CAREFUL as type= seems to be cType= # and values= seems to be dictionary= listitem.addStreamInfo(**stream) if data['art']: listitem.setArt(data['art']) for key, value in data['property'].iteritems(): listitem.setProperty(key, value) if data['subtitles']: listitem.setSubtitles(data['subtitles']) return listitem
def show_room(day, room): exp = './day[@index="{}"]/room[@name="{}"]/event'.format(day, room) for event in root.findall(exp): if not contains_videos(event.findall('./links/link')): continue event_id = event.attrib['id'] title = event.find('title').text track = event.find('track').text subtitle = event.find('subtitle').text persons = [p.text for p in event.find('./persons/person')] abstract = event.find('abstract').text duration = event.find('duration').text if abstract: abstract = abstract.replace('<p>', '').replace('</p>', '') item = ListItem(title) item.setProperty('IsPlayable', 'true') item.setInfo('video', { 'cast': persons, 'genre': track, 'plot': abstract, 'tagline': subtitle, 'title': title, }) # duration is formatted as 01:30 hour, minute = duration.split(':') seconds = timedelta(hours=int(hour), minutes=int(minute)).total_seconds() item.addStreamInfo('video', { 'duration': seconds }) url = plugin.url_for(show_event, event_id=event_id) addDirectoryItem(plugin.handle, url, item, False) endOfDirectory(plugin.handle)
def show_conference(conf): data = None try: data = http.fetch_data('conferences/' + conf) except http.FetchError: return setContent(plugin.handle, 'movies') aspect = calc_aspect(maybe_json(data, 'aspect_ratio', '16:9')) for event in sorted(data['events'], key=operator.itemgetter('title')): item = ListItem(event['title']) item.setArt({'thumb': event['thumb_url']}) item.setProperty('IsPlayable', 'true') info = { 'cast': maybe_json(event, 'persons', []), 'credits': ", ".join(maybe_json(event, 'persons', [])), 'genre': " / ".join(maybe_json(event, 'tags', [])), 'plot': maybe_json(event, 'description', ''), 'tagline': maybe_json(event, 'subtitle', '') } json_date_to_info(event, 'date', info) item.setInfo('video', info) streamInfo = {} length = maybe_json(event, 'length', 0) if length > 0: streamInfo['duration'] = length if aspect: streamInfo['aspect'] = aspect item.addStreamInfo('video', streamInfo) url = plugin.url_for(resolve_event, event=event['url'].rsplit('/', 1)[1]) addDirectoryItem(plugin.handle, url, item, False) endOfDirectory(plugin.handle)
def show_conference(conf): data = None try: data = http.fetch_data('conferences/' + conf, wants_insecure()) except http.FetchError: return setContent(plugin.handle, 'movies') aspect = calc_aspect(maybe_json(data, 'aspect_ratio', '16:9')) for event in sorted(data['events'], key=operator.itemgetter('title')): item = ListItem(event['title']) item.setThumbnailImage(event['thumb_url']) item.setProperty('IsPlayable', 'true') info = { 'cast': maybe_json(event, 'persons', []), 'credits': ", ".join(maybe_json(event, 'persons', [])), 'genre': " / ".join(maybe_json(event, 'tags', [])), 'plot': maybe_json(event, 'description', ''), 'tagline': maybe_json(event, 'subtitle', '') } json_date_to_info(event, 'date', info) item.setInfo('video', info) streamInfo = {} length = maybe_json(event, 'length', 0) if length > 0: streamInfo['duration'] = length if aspect: streamInfo['aspect'] = aspect item.addStreamInfo('video', streamInfo) url = plugin.url_for(resolve_event, event=event['url'].rsplit('/', 1)[1]) addDirectoryItem(plugin.handle, url, item, False) endOfDirectory(plugin.handle)
def show_conference(conf): data = None try: data = http.fetch_data('conferences/' + conf)['events'] except http.FetchError: return for event in sorted(data, key=operator.itemgetter('title')): item = ListItem(event['title']) item.setThumbnailImage(event['thumb_url']) item.setProperty('IsPlayable', 'true') item.setInfo('video', { 'cast': event['persons'], 'plot': event['description'], 'tagline': event['subtitle'] }) item.addStreamInfo('video', { 'duration': event['length'] }) addDirectoryItem(plugin.handle, plugin.url_for(resolve_event, event = event['url'].rsplit('/', 1)[1]), item, False) endOfDirectory(plugin.handle)
def build_livestreams_search(): search_for = Dialog().input("Enter search", "", INPUT_ALPHANUM, 0, 0).upper() any_replays = False h = plugin.handle setContent(h, "videos") f = dq.all_live_streams() for u in f: title = u[0] playback_url = u[1] thumb = u[2] user = u[3] if search_for in title.upper(): li = ListItem(user + ": " + title, iconImage=thumb) li.setProperty('IsPlayable', 'True') li.setInfo("video", {'mediatype': 'video', 'duration': 0}) li.addStreamInfo('video', {'duration': 0}) li.setArt({'icon': thumb}) li.setArt({'poster': thumb}) li.setArt({'thumb': thumb}) li.setArt({'banner': thumb}) addDirectoryItem(h, playback_url, listitem=li, isFolder=False) any_replays = True if not any_replays: li = ListItem("** NO LIVE STREAMS FOUND **", iconImage="") li.setProperty('IsPlayable', 'False') addDirectoryItem(h, "", listitem=li, isFolder=False) endOfDirectory(h)
def live(): for ch in nrktv.channels(): li = ListItem(ch.title) li.setProperty('mimetype', "application/vnd.apple.mpegurl") li.setProperty('isplayable', 'true') li.setArt({'thumb': ch.thumb, 'fanart': ch.fanart}) li.setInfo('video', {'title': ch.title}) li.addStreamInfo('video', {'codec': 'h264', 'width': 1280, 'height': 720}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, plugin.url_for(live_resolve, ch.manifest.split('/')[-1]), li, False) for rd in nrktv.radios(): li = ListItem(rd.title) li.setProperty('mimetype', "audio/mpeg") li.setProperty('isplayable', 'true') li.setArt({'thumb': rd.thumb, 'fanart': rd.fanart}) li.setInfo('video', {'title': ch.title}) li.addStreamInfo('audio', {'codec': 'aac', 'channels': 2}) addDirectoryItem(plugin.handle, plugin.url_for(live_resolve, rd.manifest.split('/')[-1]), li, False) endOfDirectory(plugin.handle)
def createListItem(item, appendShowTitle=False, appendSxxExx=False): title = item['title'] li = ListItem(title) li.setProperty('IsPlayable', "true") metadata = { 'duration': str(item['runtime']/60), 'Plot': item['plot'], 'Playcount': item['playcount'] } if "episode" in item: episode = item['episode'] metadata['Episode'] = episode if "season" in item: season = item['season'] metadata['Season'] = season if season and episode: li.setProperty('episodeno', "s%.2de%.2d" % (season, episode)) if appendSxxExx is True: title = "S%.2dE%.2d - %s" % (season, episode, title) if "firstaired" in item: metadata['Premiered'] = item['firstaired'] if "showtitle" in item: metadata['TVshowTitle'] = item['showtitle'] if appendShowTitle is True: title = item['showtitle'] + ' - ' + title if "rating" in item: metadata['Rating'] = str(round(float(item['rating']),1)) if "director" in item: metadata['Director'] = " / ".join(item['director']) if "writer" in item: metadata['Writer'] = " / ".join(item['writer']) if "cast" in item: cast = [] castandrole = [] for person in item['cast']: name = person['name'] cast.append(name) castandrole.append((name, person['role'])) metadata['Cast'] = cast metadata['CastAndRole'] = castandrole metadata['Title'] = title li.setLabel(title) li.setInfo(type="Video", infoLabels=metadata) li.setProperty('resumetime', str(item['resume']['position'])) li.setProperty('totaltime', str(item['resume']['total'])) li.setArt(item['art']) li.setThumbnailImage(item['art'].get('thumb','')) li.setArt({'icon': 'DefaultTVShows.png'}) li.setProperty('dbid', str(item['episodeid'])) li.setProperty('fanart_image', item['art'].get('tvshow.fanart','')) for key, value in item['streamdetails'].iteritems(): for stream in value: li.addStreamInfo(key, stream) return li
def createListItem(item, append_show_title=False, append_sxxexx=False): title = item['title'] li = ListItem(title) li.setProperty('IsPlayable', "true") metadata = { 'duration': str(item['runtime']/60), 'Plot': item['plot'], 'Playcount': item['playcount'] } if "episode" in item: episode = item['episode'] metadata['Episode'] = episode if "season" in item: season = item['season'] metadata['Season'] = season if season and episode: li.setProperty('episodeno', "s%.2de%.2d" % (season, episode)) if append_sxxexx is True: title = "S%.2dE%.2d - %s" % (season, episode, title) if "firstaired" in item: metadata['Premiered'] = item['firstaired'] if "showtitle" in item: metadata['TVshowTitle'] = item['showtitle'] if append_show_title is True: title = item['showtitle'] + ' - ' + title if "rating" in item: metadata['Rating'] = str(round(float(item['rating']),1)) if "director" in item: metadata['Director'] = " / ".join(item['director']) if "writer" in item: metadata['Writer'] = " / ".join(item['writer']) if "cast" in item: cast = [] castandrole = [] for person in item['cast']: name = person['name'] cast.append(name) castandrole.append((name, person['role'])) metadata['Cast'] = cast metadata['CastAndRole'] = castandrole metadata['Title'] = title li.setLabel(title) li.setInfo(type="Video", infoLabels=metadata) li.setProperty('resumetime', str(item['resume']['position'])) li.setProperty('totaltime', str(item['resume']['total'])) li.setArt(item['art']) li.setThumbnailImage(item['art'].get('thumb','')) li.setArt({'icon': 'DefaultTVShows.png'}) li.setProperty('dbid', str(item['episodeid'])) li.setProperty('fanart_image', item['art'].get('tvshow.fanart','')) try: li.addContextMenuItems([(lang(30032), 'XBMC.Action(Info)',)]) except TypeError: # Kodi f**k-up pass for key, value in item['streamdetails'].iteritems(): for stream in value: li.addStreamInfo(key, stream) return li
def fillVideoInfos( plexServer: plexapi.server.PlexServer, itemId: int, plexItem: video.Video, mediaType: str, item: ListItem ): """ Populate the provided ListItem object with existing data from plexItem and additional detail pulled from the provided plexServer :param plexServer: Plex server to gather additional details from :type plexServer: plexapi.server.PlexServer :param itemId: Unique ID of the plex Video object item :type itemId: int :param plexItem: Plex object populated with information about the item :type plexItem: video.Video :param mediaType: Kodi Media type object :type mediaType: str :param item: Instantiated Kodi ListItem to populate with additional details :type item: :class:`ListItem` """ info = { 'mediatype': mediaType, 'path': '', 'filenameandpath': '', 'title': item.getLabel() or '', 'sorttitle': '', 'originaltitle': '', 'plot': plexItem.summary or '', 'dateadded': Api.convertDateTimeToDbDateTime(plexItem.addedAt), 'year': 0, 'set': '', 'rating': 0.0, 'userrating': 0.0, 'mpaa': '', 'duration': 0, 'playcount': 0, 'lastplayed': '', 'director': [], 'writer': [], 'genre': [], 'country': [], 'tag': [] } date = None isFolder = False resumePoint = { 'totaltime': 0, 'resumetime': 0 } artwork = {} collections = [] media = [] locations = [] roles = [] if isinstance(plexItem, video.Video): info.update({ 'sorttitle': plexItem.titleSort, 'playcount': plexItem.viewCount, 'lastplayed': Api.convertDateTimeToDbDateTime(plexItem.lastViewedAt), }) info['tag'].append(plexItem.librarySectionTitle) if isinstance(plexItem, video.Movie): info.update({ 'mpaa': plexItem.contentRating or '', 'duration': Api.MillisecondsToSeconds(plexItem.duration), 'originaltitle': plexItem.originalTitle or '', 'premiered': Api.convertDateTimeToDbDate(plexItem.originallyAvailableAt), 'rating': plexItem.rating or 0.0, 'studio': Api.ListFromString(plexItem.studio), 'tagline': plexItem.tagline or '', 'userrating': plexItem.userRating or 0.0, 'year': plexItem.year or 0, 'country': Api.ListFromMediaTags(plexItem.countries), 'director': Api.ListFromMediaTags(plexItem.directors), 'genre': Api.ListFromMediaTags(plexItem.genres), 'writer': Api.ListFromMediaTags(plexItem.writers), }) date = info['premiered'] resumePoint['resumetime'] = Api.MillisecondsToSeconds(plexItem.viewOffset) collections = plexItem.collections media = plexItem.media roles = plexItem.roles elif isinstance(plexItem, library.Collections): isFolder = True elif isinstance(plexItem, video.Show): info.update({ 'mpaa': plexItem.contentRating or '', 'duration': Api.MillisecondsToSeconds(plexItem.duration), 'premiered': Api.convertDateTimeToDbDate(plexItem.originallyAvailableAt), 'rating': plexItem.rating or 0.0, 'studio': Api.ListFromString(plexItem.studio), 'year': plexItem.year or 0, 'genre': Api.ListFromMediaTags(plexItem.genres), }) date = info['premiered'] isFolder = True locations = plexItem.locations collections = plexItem.collections roles = plexItem.roles banner = plexItem.banner if banner: artwork['banner'] = plexServer.url(banner, includeToken=True) elif isinstance(plexItem, video.Season): info.update({ 'tvshowtitle': plexItem.parentTitle or '', 'season': plexItem.index, }) isFolder = True elif isinstance(plexItem, video.Episode): info.update({ 'tvshowtitle': plexItem.grandparentTitle or '', 'season': plexItem.parentIndex, 'episode': plexItem.index, 'mpaa': plexItem.contentRating or '', 'duration': Api.MillisecondsToSeconds(plexItem.duration), 'aired': Api.convertDateTimeToDbDate(plexItem.originallyAvailableAt), 'rating': plexItem.rating or 0.0, 'year': plexItem.year or 0, 'director': Api.ListFromMediaTags(plexItem.directors), 'writer': Api.ListFromMediaTags(plexItem.writers), }) date = info['aired'] resumePoint['resumetime'] = Api.MillisecondsToSeconds(plexItem.viewOffset) media = plexItem.media # handle collections / sets collections = Api.ListFromMediaTags(collections) if collections: # Kodi can only store one set per media item info['set'] = collections[0] # set the item's datetime if available if date: item.setDateTime(date) # specify whether the item is a folder or not item.setIsFolder(isFolder) # add the item's ID as a unique ID belonging to Plex item.getVideoInfoTag().setUniqueIDs({ PLEX_PROTOCOL: itemId }, PLEX_PROTOCOL) # handle actors / cast cast = [] for index, role in enumerate(roles): cast.append({ 'name': role.tag.strip(), 'role': role.role.strip(), 'order': index }) if cast: item.setCast(cast) # handle resume point if resumePoint['resumetime'] > 0 and info['duration'] > 0: resumePoint['totaltime'] = info['duration'] item.setProperties(resumePoint) # handle stream details mediaPart = None for mediaStream in media: for part in mediaStream.parts: # pick the first MediaPart with a valid file and stream URL if mediaPart is None and part.file is not None and part.key is not None: mediaPart = part for videoStream in part.videoStreams(): item.addStreamInfo('video', { 'codec': videoStream.codec, 'language': videoStream.language, 'width': videoStream.width, 'height': videoStream.height, 'duration': info['duration'] }) for audioStream in part.audioStreams(): item.addStreamInfo( 'audio', { 'codec': audioStream.codec, 'language': audioStream.language, 'channels': audioStream.channels } ) for subtitleStream in part.subtitleStreams(): item.addStreamInfo( 'subtitle', { 'language': subtitleStream.language } ) if mediaPart: # extract the absolute / actual path and the stream URL from the selected MediaPart info['path'] = mediaPart.file item.setPath(plexServer.url(mediaPart.key, includeToken=True)) elif isFolder: # for folders use locations for the path if locations: info['path'] = locations[0] item.setPath(plexServer.url(plexItem.key, includeToken=True)) info['filenameandpath'] = item.getPath() # set all the video infos item.setInfo('video', info) # handle artwork poster = None fanart = None if isinstance(plexItem, video.Video): poster = plexItem.thumbUrl fanart = plexItem.artUrl elif isinstance(plexItem, library.Collections) and plexItem.thumb: poster = plexServer.url(plexItem.thumb, includeToken=True) if poster: artwork['poster'] = poster if fanart: artwork['fanart'] = fanart if artwork: item.setArt(artwork)
def show_listing(list_items, category=None, sort='unsorted', ascending=True, content=None, cache=None, selected=None): """Show a virtual directory in Kodi""" from xbmcgui import ListItem from addon import plugin set_property('container.url', 'plugin://' + addon_id() + plugin.path) xbmcplugin.setPluginFanart(handle=plugin.handle, image=from_unicode(addon_fanart())) usemenucaching = get_setting_bool('usemenucaching', default=True) if cache is None: cache = usemenucaching elif usemenucaching is False: cache = False if content: # content is one of: files, songs, artists, albums, movies, tvshows, episodes, musicvideos xbmcplugin.setContent(plugin.handle, content=content) # Jump through hoops to get a stable breadcrumbs implementation category_label = '' if category: if not content: category_label = 'VRT NU / ' if plugin.path.startswith(('/favorites/', '/resumepoints/')): category_label += localize(30428) + ' / ' # My if isinstance(category, int): category_label += localize(category) else: category_label += category elif not content: category_label = 'VRT NU' xbmcplugin.setPluginCategory(handle=plugin.handle, category=category_label) # FIXME: Since there is no way to influence descending order, we force it here if not ascending: sort = 'unsorted' # NOTE: When showing tvshow listings and 'showoneoff' was set, force 'unsorted' if get_setting_bool( 'showoneoff', default=True) and sort == 'label' and content == 'tvshows': sort = 'unsorted' # Add all sort methods to GUI (start with preferred) xbmcplugin.addSortMethod(handle=plugin.handle, sortMethod=SORT_METHODS[sort]) for key in sorted(SORT_METHODS): if key != sort: xbmcplugin.addSortMethod(handle=plugin.handle, sortMethod=SORT_METHODS[key]) # FIXME: This does not appear to be working, we have to order it ourselves # xbmcplugin.setProperty(handle=plugin.handle, key='sort.ascending', value='true' if ascending else 'false') # if ascending: # xbmcplugin.setProperty(handle=plugin.handle, key='sort.order', value=str(SORT_METHODS[sort])) # else: # # NOTE: When descending, use unsorted # xbmcplugin.setProperty(handle=plugin.handle, key='sort.order', value=str(SORT_METHODS['unsorted'])) listing = [] showfanart = get_setting_bool('showfanart', default=True) for title_item in list_items: # Three options: # - item is a virtual directory/folder (not playable, path) # - item is a playable file (playable, path) # - item is non-actionable item (not playable, no path) is_folder = bool(not title_item.is_playable and title_item.path) is_playable = bool(title_item.is_playable and title_item.path) list_item = ListItem(label=title_item.label) prop_dict = dict( IsInternetStream='true' if is_playable else 'false', IsPlayable='true' if is_playable else 'false', IsFolder='false' if is_folder else 'true', ) if title_item.prop_dict: title_item.prop_dict.update(prop_dict) else: title_item.prop_dict = prop_dict # NOTE: The setProperties method is new in Kodi18 try: list_item.setProperties(title_item.prop_dict) except AttributeError: for key, value in list(title_item.prop_dict.items()): list_item.setProperty(key=key, value=str(value)) # FIXME: The setIsFolder method is new in Kodi18, so we cannot use it just yet # list_item.setIsFolder(is_folder) if showfanart: # Add add-on fanart when fanart is missing if not title_item.art_dict: title_item.art_dict = dict(fanart=addon_fanart()) elif not title_item.art_dict.get('fanart'): title_item.art_dict.update(fanart=addon_fanart()) list_item.setArt(title_item.art_dict) if title_item.info_dict: # type is one of: video, music, pictures, game list_item.setInfo(type='video', infoLabels=title_item.info_dict) if title_item.stream_dict: # type is one of: video, audio, subtitle list_item.addStreamInfo('video', title_item.stream_dict) if title_item.context_menu: list_item.addContextMenuItems(title_item.context_menu) url = None if title_item.path: url = title_item.path listing.append((url, list_item, is_folder)) # Jump to specific item if selected is not None: pass # from xbmcgui import getCurrentWindowId, Window # wnd = Window(getCurrentWindowId()) # wnd.getControl(wnd.getFocusId()).selectItem(selected) succeeded = xbmcplugin.addDirectoryItems(plugin.handle, listing, len(listing)) xbmcplugin.endOfDirectory(plugin.handle, succeeded, updateListing=False, cacheToDisc=cache)
def _stream(strtype, strid): # Get url _vtmgostream = vtmgostream.VtmGoStream() resolved_stream = _vtmgostream.get_stream(strtype, strid) if resolved_stream is None: # If no stream is available (i.e. geo-blocked) return # Lookup metadata _vtmgo = VtmGo() if strtype == 'movies': details = _vtmgo.get_movie(strid) description = details.description elif strtype == 'episodes': details = _vtmgo.get_episode(strid) description = details.description else: description = None # Create listitem listitem = ListItem(path=resolved_stream.url, offscreen=True) # Add video info listitem.setInfo( 'video', { 'title': resolved_stream.title, 'tvshowtitle': resolved_stream.program, 'plot': description, 'duration': resolved_stream.duration, }) listitem.addStreamInfo('video', { 'duration': resolved_stream.duration, }) # Add subtitle info listitem.setSubtitles(resolved_stream.subtitles) listitem.addStreamInfo('subtitle', { 'language': 'nl', }) listitem.setProperty('IsPlayable', 'true') listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') listitem.setMimeType('application/dash+xml') listitem.setContentLookup(False) if strtype == 'channels': listitem.setProperty('inputstream.adaptive.manifest_update_parameter', 'full') try: from inputstreamhelper import Helper except ImportError: show_ok_dialog(message='Please reboot Kodi') return is_helper = Helper('mpd', drm='com.widevine.alpha') if is_helper.check_inputstream(): listitem.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha') listitem.setProperty( 'inputstream.adaptive.license_key', _vtmgostream.create_license_key( resolved_stream.license_url, key_headers={ 'User-Agent': 'ANVSDK Android/5.0.39 (Linux; Android 6.0.1; Nexus 5)', })) xbmcplugin.setResolvedUrl(plugin.handle, True, listitem)
def show_program(program, season=None): kids = _get_kids_mode() try: _vtmGo = VtmGo(kids=kids) program_obj = _vtmGo.get_program(program) except Exception as ex: notification(message=str(ex)) raise seasons = program_obj.seasons.values() # If more than one season and no season provided, give a season-overview if season is None and len(seasons) > 1: # Add an '* All seasons' entry when configured in Kodi if get_global_setting('videolibrary.showallitems') is True: listitem = ListItem('* All seasons', offscreen=True) listitem.setArt({ 'thumb': program_obj.cover, 'fanart': program_obj.cover, }) listitem.setInfo( 'video', { 'tvshowtitle': program_obj.name, 'title': 'All seasons', 'subtitle': program_obj.description, 'plot': _format_plot(program_obj), 'set': program_obj.name, }) xbmcplugin.addDirectoryItem( plugin.handle, plugin.url_for(show_program, program=program, season='all', kids=kids), listitem, True) for s in program_obj.seasons.values(): listitem = ListItem('Season %d' % s.number, offscreen=True) listitem.setArt({ 'thumb': s.cover, 'fanart': program_obj.cover, }) listitem.setInfo( 'video', { 'tvshowtitle': program_obj.name, 'title': 'Season %d' % s.number, 'subtitle': program_obj.description, 'plot': _format_plot(program_obj), 'set': program_obj.name, 'season': season, }) xbmcplugin.addDirectoryItem( plugin.handle, plugin.url_for(show_program, program=program, season=s.number), listitem, True) xbmcplugin.setContent(plugin.handle, 'tvshows') # Sort by label. Some programs return seasons unordered. xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(plugin.handle) return if season != 'all' and season is not None: # Use the season that was selected seasons = [program_obj.seasons[int(season)]] for s in seasons: for episode in s.episodes.values(): listitem = ListItem(episode.name, offscreen=True) listitem.setArt({ 'banner': program_obj.cover, 'fanart': program_obj.cover, 'thumb': episode.cover, }) listitem.setInfo( 'video', { 'tvshowtitle': program_obj.name, 'title': episode.name, 'subtitle': program_obj.description, 'plot': _format_plot(episode), 'duration': episode.duration, 'season': episode.season, 'episode': episode.number, 'mediatype': episode.mediatype, 'set': program_obj.name, 'studio': episode.channel, 'aired': episode.aired, }) listitem.addStreamInfo('video', { 'duration': episode.duration, }) listitem.setProperty('IsPlayable', 'true') xbmcplugin.addDirectoryItem( plugin.handle, plugin.url_for(play_episode, episode=episode.id), listitem) xbmcplugin.setContent(plugin.handle, 'episodes') # Sort by episode number by default. Takes seasons into account. xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_EPISODE) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_DURATION) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.endOfDirectory(plugin.handle)
def create_listitem(item, append_show_title=False, append_sxxexx=False): """ Feed with a Kodi json item response to get a xbmcgui.ListItem() with everything set and ready. """ title = item['title'] listitem = ListItem(title) listitem.setProperty('IsPlayable', 'true') metadata = { 'duration': str(item['runtime'] / 60), 'Plot': item['plot'], 'Playcount': item['playcount'] } if 'episode' in item: episode = item['episode'] metadata['Episode'] = episode if 'season' in item: season = item['season'] metadata['Season'] = season if season and episode: listitem.setProperty('episodeno', 's%.2de%.2d' % (season, episode)) if append_sxxexx is True: title = 'S%.2dE%.2d - %s' % (season, episode, title) if 'firstaired' in item: metadata['Premiered'] = item['firstaired'] if 'showtitle' in item: metadata['TVshowTitle'] = item['showtitle'] if append_show_title is True: title = item['showtitle'] + ' - ' + title if 'rating' in item: metadata['Rating'] = str(round(float(item['rating']), 1)) if 'director' in item: metadata['Director'] = item['director'] if 'writer' in item: metadata['Writer'] = item['writer'] if 'cast' in item: cast = [] castandrole = [] for person in item['cast']: name = person['name'] cast.append(name) castandrole.append((name, person['role'])) metadata['Cast'] = cast metadata['CastAndRole'] = castandrole metadata['Title'] = title metadata['mediatype'] = 'episode' metadata['dbid'] = str(item['episodeid']) listitem.setLabel(title) listitem.setInfo(type='Video', infoLabels=metadata) listitem.setProperty('resumetime', str(item['resume']['position'])) listitem.setProperty('totaltime', str(item['resume']['total'])) listitem.setArt(item['art']) listitem.setThumbnailImage(item['art'].get('thumb', '')) listitem.setArt({'icon': 'DefaultTVShows.png'}) listitem.setProperty('fanart_image', item['art'].get('tvshow.fanart', '')) try: listitem.addContextMenuItems([( utils.lang(30032), 'XBMC.Action(Info)', )]) except TypeError: # Kodi f**k-up pass for key, value in item['streamdetails'].iteritems(): for stream in value: listitem.addStreamInfo(key, stream) return listitem
def build_episode_item(episode, show_fanart=None): #create episode listitem episode_title = episode["name"] if episode["name"] else "None" liz = ListItem(episode["name"]) #infolabels infolabels = { "title": episode["name"] } if "summary" in episode.keys(): infolabels["plot"] = episode["summary"] if "number" in episode.keys() and episode["number"].isdigit(): infolabels["episode"] = int(episode["number"]) if "published" in episode.keys(): try: infolabels["aired"] = episode['published'].rsplit('T')[0] infolabels["date"] = episode['published'].rsplit('T')[0].replace("-",".") infolabels["year"] = int(episode['published'].rsplit('T')[0].split("-")[0]) except: xbmc.log(msg='[Revision3] could not get date information', level=xbmc.LOGERROR) if "show" in episode.keys() and "name" in episode["show"].keys(): infolabels["tvshowtitle"] = episode["show"]["name"] if "duration" in episode.keys() and episode["duration"].isdigit(): infolabels["duration"] = int(episode["duration"]) #Art art = {} if "images" in episode.keys(): if "medium" in episode["images"].keys(): art["thumb"] = episode["images"]["medium"] art["icon"] = episode["images"]["medium"] art["poster"] = episode["images"]["medium"] if show_fanart: art["fanart"] = urllib.unquote(show_fanart) liz.setInfo( type="Video", infoLabels=infolabels) liz.setArt(art) #Videos url = "" if "media" in episode.keys(): media_urls = [] video_info = {} if "hd720p30" in episode["media"].keys(): media_urls.append(episode["media"]["hd720p30"]["url"]) if "large" in episode["media"].keys(): media_urls.append(episode["media"]["large"]["url"]) if "small" in episode["media"].keys(): media_urls.append(episode["media"]["small"]["url"]) #Parse user preference if len(media_urls) > 0: if kodiutils.get_setting_as_int("format") == 0: url = media_urls[0]; video_info['width'] = 1280; video_info['height'] = 720 if kodiutils.get_setting_as_int("format") == 1: url = media_urls[1] if len(media_urls) > 1 else media_urls[-1]; video_info['width'] = 854; video_info['height'] = 480 if kodiutils.get_setting_as_int("format") == 2: url = media_urls[-1]; video_info['width'] = 854; video_info['height'] = 480 #context menu items cm = [] cm.append((kodiutils.get_string(32063), 'XBMC.Action(Info)')) if url: if kodiutils.get_setting_as_bool("download") and kodiutils.get_setting("downloadPath") and xbmcvfs.exists(kodiutils.get_setting("downloadPath")): cm.append((kodiutils.get_string(32062), 'XBMC.RunPlugin(plugin://%s/download/%s/%s)' % (ADDON.getAddonInfo("id"),urllib.quote(episode_title, safe=''),urllib.quote(url, safe='')) )) liz.setPath("plugin://%s/play/%s" % (ADDON.getAddonInfo("id"),urllib.quote(url, safe='')) ) liz.setProperty('IsPlayable', 'true') liz.addStreamInfo('video', video_info) liz.addContextMenuItems(cm, replaceItems=False) return liz else: return None