def show_tvguide(): """ Shows the TV guide """ kids = kodi.kids_mode() from . import CHANNELS listing = [] for entry in CHANNELS: # Skip non-kids channels when we are in kids mode. if kids and entry.get('kids') is False: continue # Lookup the high resolution logo based on the channel name icon = '{path}/resources/logos/{logo}-white.png'.format( path=kodi.get_addon_path(), logo=entry.get('logo')) fanart = '{path}/resources/logos/{logo}.png'.format( path=kodi.get_addon_path(), logo=entry.get('logo')) listing.append( TitleItem(title=entry.get('label'), path=routing.url_for(show_tvguide_channel, channel=entry.get('key')), art_dict={ 'icon': icon, 'thumb': icon, 'fanart': fanart, }, info_dict={ 'plot': kodi.localize(30215, channel=entry.get('label')), })) kodi.show_listing(listing, 30013)
def show_livetv(): """ Shows Live TV channels """ try: channels = vtm_go.get_live_channels() except Exception as ex: kodi.show_notification(message=str(ex)) raise from . import CHANNEL_MAPPING listing = [] for channel in channels: if CHANNEL_MAPPING.get(channel.name): # Lookup the high resolution logo based on the channel name icon = '{path}/resources/logos/{logo}-white.png'.format( path=kodi.get_addon_path(), logo=CHANNEL_MAPPING.get(channel.name)) fanart = '{path}/resources/logos/{logo}.png'.format( path=kodi.get_addon_path(), logo=CHANNEL_MAPPING.get(channel.name)) else: # Fallback to the default (lower resolution) logo icon = channel.logo fanart = channel.logo title = channel.name if channel.epg: title += '[COLOR gray] | {title}[/COLOR]'.format( title=channel.epg[0].title) listing.append( TitleItem(title=title, path=routing.url_for( play, category='channels', item=channel.channel_id) + '?.pvr', art_dict={ 'icon': icon, 'thumb': icon, 'fanart': fanart, }, info_dict={ 'plot': _format_plot(channel), 'playcount': 0, 'mediatype': 'video', }, stream_dict={ 'codec': 'h264', 'height': 1080, 'width': 1920, }, is_playable=True), ) kodi.show_listing(listing, 30005)
def show_tvguide_detail(channel=None, date=None): """ Shows the programs of a specific date in the tv guide """ try: _vtmGoEpg = VtmGoEpg(kodi) epg = _vtmGoEpg.get_epg(channel=channel, date=date) except Exception as ex: kodi.show_notification(message=str(ex)) raise listing = [] for broadcast in epg.broadcasts: title = '{time} - {title}{live}'.format( time=broadcast.time.strftime('%H:%M'), title=broadcast.title, live=' [I](LIVE)[/I]' if broadcast.live else '') if broadcast.airing: title = '[B]{title}[/B]'.format(title=title) listing.append( TitleItem(title=title, path=routing.url_for( play_epg, channel=channel, program_type=broadcast.playable_type, epg_id=broadcast.uuid), art_dict={ 'icon': broadcast.image, 'thumb': broadcast.image, }, info_dict={ 'title': title, 'plot': broadcast.description, 'duration': broadcast.duration, 'mediatype': 'video', }, stream_dict={ 'duration': broadcast.duration, 'codec': 'h264', 'height': 1080, 'width': 1920, }, is_playable=True)) kodi.show_listing(listing, 30013, content='tvshows')
def show_tvguide_channel(channel): """ Shows the dates in the tv guide """ listing = [] for day in VtmGoEpg(kodi).get_dates('%A %d %B %Y'): if day.get('highlight'): title = '[B]{title}[/B]'.format(title=day.get('title')) else: title = day.get('title') listing.append( TitleItem(title=title, path=routing.url_for(show_tvguide_detail, channel=channel, date=day.get('date')), art_dict={ 'icon': 'DefaultYear.png', 'thumb': 'DefaultYear.png', }, info_dict={ 'plot': None, })) kodi.show_listing(listing, 30013, content='files')
def show_catalog(): """ Show the catalog """ kids = kodi.kids_mode() try: categories = vtm_go.get_categories() except Exception as ex: kodi.show_notification(message=str(ex)) raise listing = [] for cat in categories: listing.append( TitleItem(title=cat.title, path=routing.url_for(show_kids_catalog_category if kids else show_catalog_category, category=cat.category_id), info_dict={ 'plot': '[B]{category}[/B]'.format(category=cat.title), })) # Sort categories by default like in VTM GO. kodi.show_listing(listing, 30003, content='files')
def _generate_titleitem(item, my_list=False): """ Generate a TitleItem based on a Content. :type item: Content :rtype TitleItem """ kids = kodi.kids_mode() art_dict = { 'thumb': item.cover, } info_dict = { 'title': item.title, 'plot': item.description, } if my_list: context_menu = [( kodi.localize(30051), # Remove from My List 'XBMC.Container.Update(%s)' % routing.url_for(mylist_del if not kids else kids_mylist_del, video_type=item.video_type, content_id=item.content_id))] else: context_menu = [( kodi.localize(30050), # Add to My List 'XBMC.Container.Update(%s)' % routing.url_for(mylist_add if not kids else kids_mylist_add, video_type=item.video_type, content_id=item.content_id))] if item.video_type == Content.CONTENT_TYPE_MOVIE: # Get movie details from cache movie = vtm_go.get_movie(item.content_id, only_cache=True) if movie: art_dict.update({ 'fanart': movie.cover, }) info_dict.update({ 'plot': _format_plot(movie), 'duration': movie.duration, 'year': movie.year, 'aired': movie.aired, 'mpaa': ', '.join(movie.legal) if hasattr(movie, 'legal') and movie.legal else kodi.localize(30216), }) info_dict.update({ 'mediatype': 'movie', }) return TitleItem(title=item.title, path=routing.url_for(play, category='movies', item=item.content_id), art_dict=art_dict, info_dict=info_dict, stream_dict={ 'codec': 'h264', 'height': 1080, 'width': 1920, }, context_menu=context_menu, is_playable=True) if item.video_type == Content.CONTENT_TYPE_PROGRAM: # Get program details from cache program = vtm_go.get_program(item.content_id, only_cache=True) if program: art_dict.update({ 'fanart': program.cover, 'banner': item.cover, }) info_dict.update({ 'title': program.name, 'plot': _format_plot(program), 'mpaa': ', '.join(program.legal) if hasattr(program, 'legal') and program.legal else kodi.localize(30216), 'season': len(program.seasons), }) info_dict.update({ 'mediatype': None, }) return TitleItem(title=item.title, path=routing.url_for(show_program, program=item.content_id), art_dict=art_dict, info_dict=info_dict, context_menu=context_menu) return None
def show_program_season(program, season): """ Show a program from the catalog """ try: program_obj = vtm_go.get_program(program) except Exception as ex: kodi.show_notification(message=str(ex)) raise if season == 'all': # Show all seasons seasons = program_obj.seasons.values() else: # Show the season that was selected seasons = [program_obj.seasons[int(season)]] listing = [] for s in seasons: for episode in s.episodes.values(): listing.append( TitleItem( title=episode.name, path=routing.url_for(play, category='episodes', item=episode.episode_id), art_dict={ 'banner': program_obj.cover, 'fanart': program_obj.cover, 'thumb': episode.cover, }, info_dict={ 'tvshowtitle': program_obj.name, 'title': episode.name, 'tagline': program_obj.description, 'plot': _format_plot(episode), 'duration': episode.duration, 'season': episode.season, 'episode': episode.number, 'mediatype': 'episode', 'set': program_obj.name, 'studio': episode.channel, 'aired': episode.aired, 'mpaa': ', '.join(episode.legal) if hasattr(episode, 'legal') and episode.legal else kodi.localize(30216), }, stream_dict={ 'duration': episode.duration, 'codec': 'h264', 'height': 1080, 'width': 1920, }, is_playable=True)) # Sort by episode number by default. Takes seasons into account. kodi.show_listing(listing, 30003, content='episodes', sort='episode')
def show_program(program): """ Show a program from the catalog """ try: program_obj = vtm_go.get_program(program) except Exception as ex: kodi.show_notification(message=str(ex)) raise listing = [] # Add an '* All seasons' entry when configured in Kodi if kodi.get_global_setting('videolibrary.showallitems') is True: listing.append( TitleItem( title='* %s' % kodi.localize(30204), # * All seasons path=routing.url_for(show_program_season, program=program, season='all'), art_dict={ 'thumb': program_obj.cover, 'fanart': program_obj.cover, }, info_dict={ 'tvshowtitle': program_obj.name, 'title': kodi.localize(30204), # All seasons 'tagline': program_obj.description, 'set': program_obj.name, 'mpaa': ', '.join(program_obj.legal) if hasattr(program_obj, 'legal') and program_obj.legal else kodi.localize(30216), })) # Add the seasons for s in program_obj.seasons.values(): listing.append( TitleItem( title=kodi.localize(30205, season=s.number), # Season X path=routing.url_for(show_program_season, program=program, season=s.number), art_dict={ 'thumb': s.cover, 'fanart': program_obj.cover, }, info_dict={ 'tvshowtitle': program_obj.name, 'title': kodi.localize(30205, season=s.number), 'tagline': program_obj.description, 'set': program_obj.name, 'mpaa': ', '.join(program_obj.legal) if hasattr(program_obj, 'legal') and program_obj.legal else kodi.localize(30216), })) # Sort by label. Some programs return seasons unordered. kodi.show_listing(listing, 30003, content='tvshows', sort='label')
def show_index(): """ Show the main menu """ kids = kodi.kids_mode() listing = [] listing.extend([ TitleItem( title=kodi.localize(30001), # A-Z path=routing.url_for(show_catalog_category if not kids else show_kids_catalog_category, category='all'), art_dict=dict(icon='DefaultMovieTitle.png'), info_dict=dict(plot=kodi.localize(30002), )), TitleItem( title=kodi.localize(30003), # Catalogue path=routing.url_for( show_catalog if not kids else show_kids_catalog), art_dict=dict(icon='DefaultGenre.png'), info_dict=dict(plot=kodi.localize(30004), )), TitleItem( title=kodi.localize(30005), # Live TV path=routing.url_for( show_livetv if not kids else show_kids_livetv), art_dict=dict(icon='DefaultAddonPVRClient.png'), info_dict=dict(plot=kodi.localize(30006), )), TitleItem( title=kodi.localize(30013), # TV Guide path=routing.url_for( show_tvguide if not kids else show_kids_tvguide), art_dict={'icon': 'DefaultAddonTvInfo.png'}, info_dict={ 'plot': kodi.localize(30014), }), TitleItem( title=kodi.localize(30015), # Recommendations path=routing.url_for(show_recommendations if not kids else show_kids_recommendations), art_dict={'icon': 'DefaultFavourites.png'}, info_dict={ 'plot': kodi.localize(30016), }), TitleItem( title=kodi.localize(30017), # My List path=routing.url_for( show_mylist if not kids else show_kids_mylist), art_dict={'icon': 'DefaultPlaylist.png'}, info_dict={ 'plot': kodi.localize(30018), }), ]) # Only provide YouTube option when plugin.video.youtube is available if kodi.get_cond_visibility('System.HasAddon(plugin.video.youtube)') != 0: listing.append( TitleItem( title=kodi.localize(30007), # YouTube path=routing.url_for( show_youtube if not kids else show_kids_youtube), art_dict=dict(icon='DefaultTags.png'), info_dict=dict(plot=kodi.localize(30008), ))) listing.extend([ TitleItem( title=kodi.localize(30009), # Search path=routing.url_for( show_search if not kids else show_kids_search), art_dict=dict(icon='DefaultAddonsSearch.png'), info_dict=dict(plot=kodi.localize(30010), )), ]) if not kids: listing.append( TitleItem( title=kodi.localize(30011), # Kids Zone path=routing.url_for(show_kids_index), art_dict=dict(icon='DefaultUser.png'), info_dict=dict(plot=kodi.localize(30012), ))) kodi.show_listing(listing)