def a_to_z_menu(self, collection): import string filter_type = FILTER_TYPE.STARTS_WITH_LETTER with self.start_directory(self.handle): DirectoryItem(title=get_string(30251), url=router_url_from_string(ROUTE.FILTER, collection, filter_type, '0-9'))(self.handle) for c in string.ascii_uppercase: DirectoryItem(title=c, url=router_url_from_string( ROUTE.FILTER, collection, filter_type, c))(self.handle)
def media_menu(self, collection): with self.start_directory(self.handle): SearchItem(url=self._router.url_for(self.search, collection))( self.handle) DirectoryItem(title=get_string(30211), url=router_url_from_string(ROUTE.POPULAR, collection))(self.handle) DirectoryItem(title=get_string(30210), url=self._url_for(self.a_to_z_menu, collection))(self.handle) DirectoryItem(title=get_string(30209), url=self._url_for(self.genre_menu, collection))(self.handle)
def genre_menu(self, collection): genres = [ LANG.ACTION, LANG.ANIMATED, LANG.ADVENTURE, LANG.DOCUMENTARY, LANG.DRAMA, LANG.FANTASY, LANG.HISTORICAL, LANG.HORROR, LANG.MUSIC, LANG.IMAX, LANG.CATASTROPHIC, LANG.COMEDY, LANG.SHORT, LANG.CRIME, LANG.MUSICAL, LANG.MYSTERIOUS, LANG.EDUCATIONAL, LANG.FAIRYTALE, LANG.PSYCHOLOGICAL, LANG.JOURNALISTIC, LANG.REALITY, LANG.TRAVEL, LANG.FAMILY, LANG.ROMANTIC, LANG.SCI_FI, LANG.COMPETITION, LANG.SPORTS, LANG.STAND_UP, LANG.TALK_SHOW, LANG.TELENOVELA, LANG.THRILLER, LANG.MILITARY, LANG.WESTERN, LANG.BIOGRAPHICAL ] if settings.as_bool(SETTINGS.EXPLICIT_CONTENT): genres = genres + explicit_genres genre_pairs = {} lang_genres = [] for genre in genres: lang_genre = get_string(genre) api_genre = api_genres[genre] genre_pairs[lang_genre] = api_genre lang_genres.append(lang_genre) lang_genres.sort() with self.start_directory(self.handle): for lang_genre in lang_genres: DirectoryItem(title=lang_genre, url=router_url_from_string( ROUTE.FILTER, collection, FILTER_TYPE.GENRE, genre_pairs[lang_genre]))(self.handle)
def genre_menu(self, collection): genres = [ LANG.ACTION, LANG.ANIMATED, LANG.ADVENTURE, LANG.DOCUMENTARY, LANG.DRAMA, LANG.FANTASY, LANG.HISTORICAL, LANG.HORROR, LANG.MUSIC, LANG.IMAX, LANG.CATASTROPHIC, LANG.COMEDY, LANG.SHORT, LANG.CRIME, LANG.MUSICAL, LANG.MYSTERIOUS, LANG.EDUCATIONAL, LANG.FAIRYTALE, LANG.PSYCHOLOGICAL, LANG.JOURNALISTIC, LANG.REALITY, LANG.TRAVEL, LANG.FAMILY, LANG.ROMANTIC, LANG.SCI_FI, LANG.COMPETITION, LANG.SPORTS, LANG.STAND_UP, LANG.TALK_SHOW, LANG.TELENOVELA, LANG.THRILLER, LANG.MILITARY, LANG.WESTERN, LANG.BIOGRAPHICAL ] if settings.as_bool(SETTINGS.EXPLICIT_CONTENT): genres = genres + explicit_genres genres = [{ 'lang_id': genre, 'string': get_string(genre) } for genre in genres] genres.sort(key=operator.itemgetter('string')) with self.start_directory(self.handle): for genre in genres: DirectoryItem(title=genre.get('string'), url=router_url_from_string( ROUTE.FILTER, collection, FILTER_TYPE.GENRE, Url.encode_param( [api_genres[genre.get('lang_id')]]), ORDER.DESCENDING))(self.handle)
def build_season_list_gui(self, season_list, media_id): gui_season_list = [] for i, season in enumerate(season_list, start=1): title = STRINGS.SEASON_TITLE.format(get_string(30920), str(i)) url = self._router.url_for(self.select_episode, media_id, i - 1) item = DirectoryItem(title, url) gui_season_list.append(item) return gui_season_list
def media_menu(self, collection): with self.start_directory(self.handle): DirectoryItem(title=get_string(LANG.POPULAR), url=router_url_from_string(ROUTE.POPULAR, collection))(self.handle) DirectoryItem(title=get_string(LANG.NEWS), url=router_url_from_string( ROUTE.SORT, collection, SORT_TYPE.AIRED, ORDER.DESCENDING))(self.handle) DirectoryItem(title=get_string(LANG.LAST_ADDED), url=router_url_from_string( ROUTE.SORT, collection, SORT_TYPE.DATE_ADDED, ORDER.DESCENDING))(self.handle) DirectoryItem(title=get_string(LANG.A_Z), url=self._url_for(self.a_to_z_menu, collection))(self.handle) DirectoryItem(title=get_string(LANG.GENRE), url=self._url_for(self.genre_menu, collection))(self.handle) self.add_extra_items(collection)
def a_to_z_menu(self, collection): import string filter_type = FILTER_TYPE.STARTS_WITH zero_nine = [i for i in range(10)] _0_9 = get_string(LANG.ZERO_NINE) letter_counts = self._on_a_to_z_menu( collection, filter_type, [c for c in string.ascii_lowercase] + zero_nine) with self.start_directory(self.handle): DirectoryItem(title=self._a_to_z_title( _0_9, sum([letter_counts[str(i)] for i in range(10)])), url=router_url_from_string( ROUTE.FILTER, collection, filter_type, Url.encode_param(zero_nine), ORDER.ASCENDING))(self.handle) for c in string.ascii_lowercase: letter_count = letter_counts.get(c) DirectoryItem(title=self._a_to_z_title(c.upper(), letter_count), url=self._url_for(self.a_to_z_submenu, collection, c, letter_count))(self.handle)
def main_menu(self): logger.debug('Rendering main menu') with self.start_directory(self.handle): SearchItem(url=self._router.url_for(self.search, COLLECTION.ALL))( self.handle) DirectoryItem(title=get_string(LANG.NEWS), url=router_url_from_string( ROUTE.SORT, COLLECTION.ALL, SORT_TYPE.AIRED, ORDER.DESCENDING))(self.handle) DirectoryItem(title=get_string(LANG.LAST_ADDED), url=router_url_from_string( ROUTE.SORT, COLLECTION.ALL, SORT_TYPE.DATE_ADDED, ORDER.DESCENDING))(self.handle) MoviesItem( url=self._router.url_for(self.media_menu, COLLECTION.MOVIES))( self.handle) TvShowsItem(url=self._router.url_for( self.media_menu, COLLECTION.TV_SHOWS))(self.handle) WatchHistoryItem(url=router_url_from_string(ROUTE.WATCHED))( self.handle) SettingsItem( url=self._router.url_for(self.command, COMMAND.OPEN_SETTINGS))( self.handle) return
def _a_to_z_submenu_items(self, collection, filter_type, previous_letter, letter_counts, previous_letter_count): import string for c in string.ascii_lowercase: letters = previous_letter + c count = letter_counts.get(letters) if count > 0: if count <= a_z_threshold_options[settings.as_int( SETTINGS.A_Z_THRESHOLD)]: url = router_url_from_string(ROUTE.FILTER, collection, filter_type, Url.encode_param([letters]), ORDER.ASCENDING) else: url = self._url_for(self.a_to_z_submenu, collection, letters, previous_letter_count) DirectoryItem(title=self._a_to_z_title(letters.upper(), count), url=url)(self.handle)
def add_extra_items(self, collection): if collection == COLLECTION.MOVIES: DirectoryItem(title=get_string(LANG.CSFD_TIPS), url=router_url_from_string(ROUTE.CSFD_TIPS, collection))(self.handle)
def next_page_item(collection, pagination): body = json.dumps(pagination['body']) return DirectoryItem( title=MediaListRenderer.next_page_title(pagination['page'], pagination['pageCount']), url=router_url_from_string(ROUTE.NEXT_PAGE, collection, Url.quote_plus(pagination['next']), Url.encode_param(body)))
def next_page_item(self, media_list): return DirectoryItem( title=self.next_page_title(media_list['page'], media_list['pageCount']), url=router_url_from_string(ROUTE.NEXT_PAGE, self.get_collection(), Url.quote_plus(media_list['next'])))