def show_channel_guide(self, channel_id): """ Shows the dates in the tv guide. :param str channel_id: The channel for which we want to show an EPG. """ listing = [] for day in self._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=kodiutils.url_for('show_channel_guide_detail', channel_id=channel_id, date=day.get('key')), art_dict=dict( icon='DefaultYear.png', thumb='DefaultYear.png', ), info_dict=dict( plot=None, date=day.get('date'), ), )) kodiutils.show_listing(listing, 30013, content='files')
def show_search(self, query=None): """ Shows the search dialog :type query: str """ if not query: # Ask for query query = kodiutils.get_search_string( heading=kodiutils.localize(30009)) # Search if not query: kodiutils.end_of_directory() return # Do search try: items = self._search.search(query) except Exception as ex: # pylint: disable=broad-except kodiutils.notification(message=str(ex)) kodiutils.end_of_directory() return # Display results listing = [self._menu.generate_titleitem(item) for item in items] # Sort like we get our results back. kodiutils.show_listing(listing, 30009, content='tvshows')
def show_category(self, uuid): """ Shows a category """ programs = self._api.get_category_content(int(uuid)) listing = [Menu.generate_titleitem(program) for program in programs] kodiutils.show_listing(listing, 30003, content='tvshows')
def show_catalog_category(self, category=None): """ Show a category in the catalog :type category: str """ try: items = self._vtm_go.get_items(category) except ApiUpdateRequired: kodiutils.ok_dialog(message=kodiutils.localize( 30705)) # The VTM GO Service has been updated... return except Exception as ex: # pylint: disable=broad-except _LOGGER.error("%s", ex) kodiutils.ok_dialog(message="%s" % ex) return listing = [] for item in items: listing.append(self._menu.generate_titleitem(item)) # Sort items by label, but don't put folders at the top. # Used for A-Z listing or when movies and episodes are mixed. kodiutils.show_listing( listing, 30003, content='movies' if category == 'films' else 'tvshows', sort=['label', 'year', 'duration'])
def show_library_movies(self, movie=None): """ Return a list of the movies that should be exported. """ if movie is None: if kodiutils.get_setting_int( 'library_movies') == LIBRARY_FULL_CATALOG: # Full catalog # Use cache if available, fetch from api otherwise so we get rich metadata for new content items = self._api.get_items(content_filter=Movie, cache=CACHE_AUTO) else: # Only favourites, use cache if available, fetch from api otherwise items = self._api.get_mylist(content_filter=Movie) else: items = [self._api.get_movie(movie)] listing = [] for item in items: title_item = Menu.generate_titleitem(item) # title_item.path = kodiutils.url_for('library_movies', movie=item.movie_id) # We need a trailing / title_item.path = 'plugin://plugin.video.vtm.go/library/movies/?movie=%s' % item.movie_id listing.append(title_item) kodiutils.show_listing(listing, 30003, content='movies', sort=['label', 'year', 'duration'])
def show_program_season(self, program_id, season_uuid): """ Show the episodes of a program from the catalog :type program_id: str :type season_uuid: str """ try: program = self._api.get_program(program_id) except UnavailableException: kodiutils.ok_dialog(message=kodiutils.localize( 30717)) # This program is not available in the catalogue. kodiutils.end_of_directory() return if season_uuid == "-1": # Show all episodes episodes = program.episodes else: # Show the episodes of the season that was selected episodes = [ e for e in program.episodes if e.season_uuid == season_uuid ] listing = [Menu.generate_titleitem(episode) for episode in episodes] # Sort by episode number by default. Takes seasons into account. kodiutils.show_listing(listing, 30003, content='episodes', sort=['episode', 'duration'])
def show_library_tvshows(self, program=None): """ Return a list of the series that should be exported. """ if program is None: if kodiutils.get_setting_int( 'library_tvshows') == LIBRARY_FULL_CATALOG: # Full catalog # Use cache if available, fetch from api otherwise so we get rich metadata for new content # NOTE: We should probably use CACHE_PREVENT here, so we can pick up new episodes, but we can't since that would # require a massive amount of API calls for each update. We do this only for programs in 'My list'. items = self._api.get_items(content_filter=Program, cache=CACHE_AUTO) else: # Only favourites, don't use cache, fetch from api # If we use CACHE_AUTO, we will miss updates until the user manually opens the program in the Add-on items = self._api.get_mylist(content_filter=Program, cache=CACHE_PREVENT) else: # Fetch only a single program items = [self._api.get_program(program, cache=CACHE_PREVENT)] listing = [] for item in items: title_item = Menu.generate_titleitem(item) # title_item.path = kodiutils.url_for('library_tvshows', program=item.program_id) # We need a trailing / title_item.path = 'plugin://plugin.video.vtm.go/library/tvshows/?program={program_id}'.format( program_id=item.program_id) listing.append(title_item) kodiutils.show_listing(listing, 30003, content='tvshows', sort=['label', 'year', 'duration'])
def show_search(self, query=None): """ Shows the search dialog. :param str query: The query to search for. """ if not query: # Ask for query query = kodiutils.get_search_string( heading=kodiutils.localize(30009)) # Search if not query: kodiutils.end_of_directory() return # Do search items = self._search_api.search(query) # Generate the results listing = [] for item in items: if isinstance(item, Program): if item.series_id: listing.append(Menu.generate_titleitem_series(item)) else: listing.append(Menu.generate_titleitem_program(item)) if isinstance(item, Channel) and item.available is not False: listing.append(Menu.generate_titleitem_channel(item)) # Sort like we get our results back. kodiutils.show_listing(listing, 30009, content='files')
def show_recommendations_category(self, storefront, category): """ Show the items in a recommendations category. :type storefront: str :type category: str """ result = self._api.get_storefront_category(storefront, category) show_unavailable = kodiutils.get_setting_bool( 'interface_show_unavailable') listing = [] for item in result.content: if show_unavailable or item.available: listing.append(Menu.generate_titleitem(item)) if storefront == STOREFRONT_SERIES: content = 'tvshows' elif storefront == STOREFRONT_MOVIES: content = 'movies' else: content = 'tvshows' # Fallback to a list of tvshows kodiutils.show_listing(listing, result.title, content=content, sort=['unsorted', 'label', 'year', 'duration'])
def show_search(self, query=None): """ Shows the search dialog. :type query: str """ if not query: # Ask for query query = kodiutils.get_search_string( heading=kodiutils.localize(30009)) # Search Streamz if not query: kodiutils.end_of_directory() return # Do search try: items = self._api.do_search(query) except Exception as ex: # pylint: disable=broad-except kodiutils.notification(message=str(ex)) kodiutils.end_of_directory() return # Display results show_unavailable = kodiutils.get_setting_bool( 'interface_show_unavailable') listing = [] for item in items: if show_unavailable or item.available: listing.append(Menu.generate_titleitem(item)) # Sort like we get our results back. kodiutils.show_listing(listing, 30009, content='tvshows')
def show_mainmenu(): """ Show the main menu """ listing = [ TitleItem( title=kodiutils.localize(30001), # A-Z path=kodiutils.url_for('show_catalog'), art_dict=dict( icon='DefaultMovieTitle.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30002), )), TitleItem( title=kodiutils.localize(30007), # TV Channels path=kodiutils.url_for('show_channels'), art_dict=dict( icon='DefaultAddonPVRClient.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30008), )), TitleItem( title=kodiutils.localize(30009), # Search path=kodiutils.url_for('show_search'), art_dict=dict( icon='DefaultAddonsSearch.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30010), )) ] kodiutils.show_listing(listing, sort=['unsorted'])
def show_recommendations_category(self, storefront, category): """ Show the items in a recommendations category. :type storefront: str :type category: str """ try: recommendations = self._vtm_go.get_recommendations(storefront) except ApiUpdateRequired: kodiutils.ok_dialog(message=kodiutils.localize( 30705)) # The VTM GO Service has been updated... return except Exception as ex: # pylint: disable=broad-except _LOGGER.error("%s", ex) kodiutils.ok_dialog(message="%s" % ex) return listing = [] for cat in recommendations: # Only show the requested category if cat.category_id != category: continue for item in cat.content: listing.append(self._menu.generate_titleitem(item)) # Sort categories by default like in VTM GO. kodiutils.show_listing(listing, 30015, content='tvshows')
def show_channels(self): """ Shows TV channels. """ channels = self._channel_api.get_channels( filter_pin=kodiutils.get_setting_int( 'interface_adult') == SETTINGS_ADULT_HIDE) # Load EPG details for the next 6 hours date_now = datetime.now(dateutil.tz.UTC) date_from = date_now.replace(minute=0, second=0, microsecond=0) date_to = (date_from + timedelta(hours=6)) epg = self._epg_api.get_guide([channel.uid for channel in channels], date_from, date_to) for channel in channels: shows = [ show for show in epg.get(channel.uid, {}) if show.end > date_now ] try: channel.epg_now = shows[0] except (IndexError, KeyError): pass try: channel.epg_next = shows[1] except (IndexError, KeyError): pass listing = [] for item in channels: title_item = Menu.generate_titleitem_channel(item) title_item.path = kodiutils.url_for('show_channel', channel_id=item.get_combi_id()) title_item.is_playable = False listing.append(title_item) kodiutils.show_listing(listing, 30007)
def show_channel(self, channel): """ Shows the dates in the tv guide :type channel: str """ listing = [] for day in self.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=kodiutils.url_for('show_channel_tvguide_detail', channel=channel, date=day.get('key')), art_dict={ 'icon': 'DefaultYear.png', 'thumb': 'DefaultYear.png', }, info_dict={ 'plot': None, 'date': day.get('date'), })) kodiutils.show_listing(listing, 30013, content='files', sort=['date'])
def show_continuewatching(self): """ Show the items in "Continue Watching" """ try: mylist = self._vtm_go.get_swimlane('continue-watching') except ApiUpdateRequired: kodiutils.ok_dialog(message=kodiutils.localize( 30705)) # The VTM GO Service has been updated... return except Exception as ex: # pylint: disable=broad-except _LOGGER.error("%s", ex) kodiutils.ok_dialog(message="%s" % ex) return listing = [] for item in mylist: titleitem = self._menu.generate_titleitem(item, progress=True) # Add Program Name to title since this list contains episodes from multiple programs title = '%s - %s' % (titleitem.info_dict.get('tvshowtitle'), titleitem.info_dict.get('title')) titleitem.info_dict['title'] = title listing.append(titleitem) # Sort categories by default like in VTM GO. kodiutils.show_listing(listing, 30019, content='episodes', sort='label')
def show_catalog(self): """ Show the catalog """ try: categories = self._vtm_go.get_categories() except ApiUpdateRequired: kodiutils.ok_dialog(message=kodiutils.localize( 30705)) # The VTM GO Service has been updated... return except Exception as ex: # pylint: disable=broad-except _LOGGER.error("%s", ex) kodiutils.ok_dialog(message="%s" % ex) return listing = [] for cat in categories: listing.append( kodiutils.TitleItem( title=cat.title, path=kodiutils.url_for('show_catalog_category', category=cat.category_id), info_dict=dict( plot='[B]{category}[/B]'.format(category=cat.title), ), )) # Sort categories by default like in VTM GO. kodiutils.show_listing(listing, 30003, content='files')
def show_tvguide_channel(self, channel): """ Shows the dates in the tv guide :type channel: str """ listing = [] for day in self._vtm_go_epg.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(kodiutils.TitleItem( title=title, path=kodiutils.url_for('show_tvguide_detail', channel=channel, date=day.get('key')), art_dict=dict( icon='DefaultYear.png', thumb='DefaultYear.png', ), info_dict=dict( plot=None, date=day.get('date'), ), )) kodiutils.show_listing(listing, 30013, content='files', sort=['date'])
def show_recommendations_category(self, storefront, category): """ Show the items in a recommendations category. :type storefront: str :type category: str """ try: result = self._vtm_go.get_storefront_category(storefront, category) except ApiUpdateRequired: kodiutils.ok_dialog(message=kodiutils.localize( 30705)) # The VTM GO Service has been updated... return except Exception as ex: # pylint: disable=broad-except _LOGGER.error("%s", ex) kodiutils.ok_dialog(message="%s" % ex) return listing = [] for item in result.content: listing.append(Menu.generate_titleitem(item)) if storefront == STOREFRONT_SERIES: content = 'tvshows' elif storefront == STOREFRONT_MOVIES: content = 'movies' else: content = 'tvshows' # Fallback to a list of tvshows kodiutils.show_listing(listing, result.title, content=content, sort=['unsorted', 'label', 'year', 'duration'])
def show_program_season(self, program, season): """ Show the episodes of a program from the catalog :type program: str :type season: int """ try: program_obj = self._vtm_go.get_program( program ) # Use CACHE_AUTO since the data is just refreshed in show_program except UnavailableException: kodiutils.ok_dialog( message=kodiutils.localize(30717) ) # This program is not available in the VTM GO catalogue. kodiutils.end_of_directory() return if season == -1: # Show all seasons seasons = list(program_obj.seasons.values()) else: # Show the season that was selected seasons = [program_obj.seasons[season]] listing = [ self._menu.generate_titleitem(e) for s in seasons for e in list(s.episodes.values()) ] # Sort by episode number by default. Takes seasons into account. kodiutils.show_listing(listing, 30003, content='episodes', sort=['episode', 'duration'])
def show_recommendations(self, storefront): """ Show the recommendations. :type storefront: str """ results = self._api.get_storefront(storefront) show_unavailable = kodiutils.get_setting_bool( 'interface_show_unavailable') listing = [] for item in results: if isinstance(item, Category): listing.append( TitleItem( title=item.title, path=kodiutils.url_for('show_recommendations_category', storefront=storefront, category=item.category_id), info_dict=dict(plot='[B]{category}[/B]'.format( category=item.title), ), )) else: if show_unavailable or item.available: listing.append(Menu.generate_titleitem(item)) if storefront == STOREFRONT_SERIES: label = 30005 # Series elif storefront == STOREFRONT_MOVIES: label = 30003 # Movies else: label = 30015 # Recommendations kodiutils.show_listing(listing, label, content='files')
def show_channel_replay_series(self, series_id): """ Shows the related programs of the specified channel. :param str series_id: The series we want to show. """ programs = self._channel_api.get_series(series_id) listing = [Menu.generate_titleitem_program(item) for item in programs] kodiutils.show_listing(listing, 30013, content='episodes')
def show_mainmenu(): """ Show the main menu """ listing = [ TitleItem( title=kodiutils.localize(30001), # A-Z path=kodiutils.url_for('show_catalog'), art_dict=dict( icon='DefaultMovieTitle.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30002), )), TitleItem( title=kodiutils.localize(30007), # TV Channels path=kodiutils.url_for('show_channels'), art_dict=dict( icon='DefaultAddonPVRClient.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30008), )), TitleItem( title=kodiutils.localize(30003), # Catalog path=kodiutils.url_for('show_categories'), art_dict=dict( icon='DefaultGenre.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30004), )), TitleItem( title=kodiutils.localize(30005), # Recommendations path=kodiutils.url_for('show_recommendations'), art_dict=dict( icon='DefaultFavourites.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30006), )), TitleItem( title=kodiutils.localize(30011), # My List path=kodiutils.url_for('show_mylist'), art_dict=dict( icon='DefaultPlaylist.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30012), )), TitleItem( title=kodiutils.localize(30009), # Search path=kodiutils.url_for('show_search'), art_dict=dict( icon='DefaultAddonsSearch.png', fanart=kodiutils.get_addon_info('fanart'), ), info_dict=dict(plot=kodiutils.localize(30010), )) ] kodiutils.show_listing(listing, sort=['unsorted'])
def show_mylist(self): """ Show the items in "My List". """ mylist = self._api.get_swimlane('my-list') listing = [] for item in mylist: item.my_list = True listing.append(Menu.generate_titleitem(item)) # Sort categories by default like in Streamz. kodiutils.show_listing(listing, 30017, content='tvshows', sort=['unsorted', 'label', 'year', 'duration'])
def show_catalog(self): """ Show all the programs of all channels """ try: items = self._api.get_programs() except Exception as ex: kodiutils.notification(message=str(ex)) raise listing = [Menu.generate_titleitem(item) for item in items] # Sort items by title # Used for A-Z listing or when movies and episodes are mixed. kodiutils.show_listing(listing, 30003, content='tvshows', sort='title')
def show_catalog_category(self, category=None): """ Show a category in the catalog. :type category: str """ items = self._api.get_items(category) listing = [] for item in items: listing.append(Menu.generate_titleitem(item)) # Sort items by label, but don't put folders at the top. # Used for A-Z listing or when movies and episodes are mixed. kodiutils.show_listing(listing, 30003, content='movies' if category == 'films' else 'tvshows', sort=['label', 'year', 'duration'])
def show_catalog(self): """ Show all the programs of all channels """ try: items = [] for channel in list(CHANNELS): items.extend(self._api.get_programs(channel)) except Exception as ex: kodiutils.notification(message=str(ex)) raise listing = [self._menu.generate_titleitem(item) for item in items] # Sort items by label, but don't put folders at the top. # Used for A-Z listing or when movies and episodes are mixed. kodiutils.show_listing(listing, 30003, content='tvshows', sort='label')
def show_categories(self): """ Shows the categories """ categories = self._api.get_categories() listing = [] for category in categories: listing.append( TitleItem(title=category.title, path=kodiutils.url_for('show_category', category=category.uuid), info_dict={ 'title': category.title, })) kodiutils.show_listing(listing, 30003, sort=['title'])
def show_library_tvshows_program(self, program): """ Return a list of the episodes that should be exported. """ program_obj = self._api.get_program(program) listing = [] for season in list(program_obj.seasons.values()): for item in list(season.episodes.values()): title_item = Menu.generate_titleitem(item) # title_item.path = kodiutils.url_for('library_tvshows', program=item.program_id, episode=item.episode_id) title_item.path = 'plugin://plugin.video.streamz/library/tvshows/?program={program_id}&episode={episode_id}'.format(program_id=item.program_id, episode_id=item.episode_id) listing.append(title_item) # Sort by episode number by default. Takes seasons into account. kodiutils.show_listing(listing, 30003, content='episodes', sort=['episode', 'duration'])
def show_channel_menu(key): """ Shows a TV channel :type key: str """ channel = CHANNELS[key] # Lookup the high resolution logo based on the channel name fanart = '{path}/resources/logos/{logo}'.format(path=kodiutils.addon_path(), logo=channel.get('background')) listing = [ TitleItem( title=kodiutils.localize(30053, channel=channel.get('name')), # TV Guide for {channel} path=kodiutils.url_for('show_tvguide_channel', channel=key), art_dict={ 'icon': 'DefaultAddonTvInfo.png', 'fanart': fanart, }, info_dict={ 'plot': kodiutils.localize(30054, channel=channel.get('name')), # Browse the TV Guide for {channel} } ), TitleItem( title=kodiutils.localize(30055, channel=channel.get('name')), # Catalog for {channel} path=kodiutils.url_for('show_catalog_channel', channel=key), art_dict={ 'icon': 'DefaultMovieTitle.png', 'fanart': fanart, }, info_dict={ 'plot': kodiutils.localize(30056, channel=channel.get('name')), # Browse the Catalog for {channel} } ) ] # Add YouTube channels if kodiutils.get_cond_visibility('System.HasAddon(plugin.video.youtube)') != 0: for youtube in channel.get('youtube', []): listing.append( TitleItem( title=kodiutils.localize(30206, label=youtube.get('label')), # Watch {label} on YouTube path=youtube.get('path'), info_dict={ 'plot': kodiutils.localize(30206, label=youtube.get('label')), # Watch {label} on YouTube } ) ) kodiutils.show_listing(listing, 30007, sort=['unsorted'])
def show_catalog(self): """ Show the catalog. """ categories = self._api.get_categories() listing = [] for cat in categories: listing.append(TitleItem( title=cat.title, path=kodiutils.url_for('show_catalog_category', category=cat.category_id), info_dict=dict( plot='[B]{category}[/B]'.format(category=cat.title), ), )) # Sort categories by default like in Streamz. kodiutils.show_listing(listing, 30003, content='files')