def genre_get(self, genre, page): from resources.lib.modules import kitsu_api if genre is None: genres = kitsu_api.KitsuBrowser().all_categories() genres = sorted(genres, key=lambda a: (a['name'])) genre_display_list = [] for a in genres: genre_display_list.append(a['name']) genre_multiselect = tools.showDialog.multiselect( tools.addonName + ": Genre Selection", genre_display_list) if genre_multiselect is None: return genre_selection = [] for selection in genre_multiselect: genre_selection.append(genres[selection]['slug']) genre_string = ','.join(genre_selection) else: genre_string = genre anime = kitsu_api.KitsuBrowser().search(genre=genre_string, page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem( 'Next Page...', 'genre_get&genre=%s&page=%s' % (genre_string, str(page + 1)), None, None) tools.closeDirectory('tvshows')
def season_get(self, season, page): if season is None: seasons = [ {'name': 'Winter', 'slug': 'winter'}, {'name': 'Spring', 'slug': 'spring'}, {'name': 'Summer', 'slug': 'summer'}, {'name': 'Fall', 'slug': 'fall'} ] season_display_list = [] for a in seasons: season_display_list.append(a['name']) season_multiselect = tools.showDialog.multiselect(tools.addonName + ": Season Selection", season_display_list) if season_multiselect is None: return season_selection = [] for selection in season_multiselect: season_selection.append(seasons[selection]['slug']) season_string = ','.join(season_selection) else: season_string = season anime = kitsu_api.KitsuBrowser().search(season=season_string, page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'season_get&season=%s&page=%s' % (season_string, str(page+1)), None, None) tools.closeDirectory('tvshows')
def rating_get(self, rating, page): if rating is None: ratings = [{ 'name': 'General Audiences', 'slug': 'G' }, { 'name': 'Parental Guidence', 'slug': 'PG' }, { 'name': 'Restricted', 'slug': 'R' }] rating_display_list = [] for a in ratings: rating_display_list.append(a['name']) rating_multiselect = tools.showDialog.multiselect( tools.addonName + ": Rating Selection", rating_display_list) if rating_multiselect is None: return rating_selection = [] for selection in rating_multiselect: rating_selection.append(ratings[selection]['slug']) rating_string = ','.join(rating_selection) else: rating_string = rating anime = kitsu_api.KitsuBrowser().search(rating=rating_string, page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem( 'Next Page...', 'rating_get&rating=%s&page=%s' % (rating_string, str(page + 1)), None, None) tools.closeDirectory('tvshows')
def myAniList(self): tools.addDirectoryItem('Currently Watching', 'get_list&site=anilist&list=current', {'plot': 'Explore currently watching anime on AniList.', 'description': 'Explore currently watching anime on AniList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'anilist.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Finished', 'get_list&site=anilist&list=finished', {'plot': 'Explore finished anime on AniList.', 'description': 'Explore finished anime on AniList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'anilist.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Dropped', 'get_list&site=anilist&list=dropped', {'plot': 'Explore dropped anime on AniList.', 'description': 'Explore dropped anime on AniList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'anilist.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('On Hold', 'get_list&site=anilist&list=on_hold', {'plot': 'Explore on hold anime on AniList.', 'description': 'Explore on hold anime on AniList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'anilist.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Planned', 'get_list&site=anilist&list=planned', {'plot': 'Explore planned anime on AniList.', 'description': 'Explore planned anime on AniList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'anilist.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.closeDirectory('tvshows')
def franchise(self, args, page): show_info = json.loads(tools.unquote(args)) anime = kitsu_api.KitsuBrowser().franchise(id=show_info['id']) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'franchise&page=%s' % str(page+1), None, None, actionArgs=tools.quote(tools.unquote(args))) tools.closeDirectory('episodes')
def subtype_list(self): subtypes = [{ 'name': 'TV Shows', 'slug': 'tv' }, { 'name': 'Movies', 'slug': 'movie' }, { 'name': 'OVA', 'slug': 'ova' }, { 'name': 'ONA', 'slug': 'ona' }, { 'name': 'Specials', 'slug': 'special' }] tools.addDirectoryItem('Multi Select...', 'subtype_get', None, None) for a in subtypes: tools.addDirectoryItem(a['name'], 'subtype_get&subtype=%s' % a['slug'], None, None) tools.closeDirectory('addons')
def subtype_get(self, subtype, page): if subtype is None: subtypes = [ {'name': 'TV Shows', 'slug': 'tv'}, {'name': 'Movies', 'slug': 'movie'}, {'name': 'OVA', 'slug': 'ova'}, {'name': 'ONA', 'slug': 'ona'}, {'name': 'Specials', 'slug': 'special'} ] subtype_display_list = [] for a in subtypes: subtype_display_list.append(a['name']) subtype_multiselect = tools.showDialog.multiselect(tools.addonName + ": Subtype Selection", subtype_display_list) if subtype_multiselect is None: return subtype_selection = [] for selection in subtype_multiselect: subtype_selection.append(subtypes[selection]['slug']) subtype_string = ','.join(subtype_selection) else: subtype_string = subtype anime = kitsu_api.KitsuBrowser().search(subtype=subtype_string, page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'subtype_get&subtype=%s&page=%s' % (subtype_string, str(page+1)), None, None) tools.closeDirectory('tvshows')
def year_get(self, year, page): if year is None: from datetime import datetime current_year = int(datetime.today().year) years = [] for a in range(1907, current_year + 1): years.append(a) years = sorted(years, reverse=True) year_display_list = [] for a in years: year_display_list.append(str(a)) year_multiselect = tools.showDialog.multiselect(tools.addonName + ": Year Selection", year_display_list) if year_multiselect is None: return year_selection = [] for selection in year_multiselect: year_selection.append(year_display_list[selection]) year_string = ','.join(year_selection) else: year_string = year anime = kitsu_api.KitsuBrowser().search(year=year_string, page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'year_get&year=%s&page=%s' % (year_string, str(page+1)), None, None) tools.closeDirectory('tvshows')
def get_list_test(self, site, list): from resources.lib.modules import accounts_test as accounts anime = accounts.Lists().get(site, list) if site == 'kitsu': self.list_builder(anime) else: self.list_builder_alt(anime, site) tools.closeDirectory('tvshows')
def myAccounts(self): if self.kitsu_access: tools.addDirectoryItem('My Kitsu - %s' % self.kitsu_user, 'my_kitsu', {'plot': 'Explore your lists on Kitsu.', 'description': 'Explore your lists on Kitsu.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'kitsu.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) if self.mal_access: tools.addDirectoryItem('My MAL - %s' % self.mal_user, 'my_mal', {'plot': 'Explore your lists on MyAnimeList.', 'description': 'Explore your lists on MyAnimeList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'mal.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) if self.ani_access: tools.addDirectoryItem('My AniList - %s' % self.ani_user, 'my_anilist', {'plot': 'Explore your lists on AniList.', 'description': 'Explore your lists on AniList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'anilist.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.closeDirectory('tvshows')
def highest_rated(self, page): anime = kitsu_api.KitsuBrowser().highest_rated(page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'highest_rated&page=%s' % str(page + 1), None, None) tools.closeDirectory('tvshows')
def most_popular(self, page): anime = kitsu_api.KitsuBrowser().most_popular(page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'most_popular&page=%s' % (page + 1), None, None) tools.closeDirectory('tvshows')
def top_upcoming(self, page): anime = kitsu_api.KitsuBrowser().top_upcoming(page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'upcoming&page=%s' % str(page + 1), None, None) tools.closeDirectory('tvshows')
def genre_list(self): from resources.lib.modules import kitsu_api genres = kitsu_api.KitsuBrowser().all_categories() genres = sorted(genres, key= lambda a: (a['name'])) tools.addDirectoryItem('Multi Select...', 'genre_get', None, None) for a in genres: tools.addDirectoryItem(a['name'], 'genre_get&genre=%s' % a['slug'], None, None) tools.closeDirectory('addons')
def top_by_season(self, season, year, page): anime = kitsu_api.KitsuBrowser().search(season=season, year=year, page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem( 'Next Page...', 'top_by_season&season=%s&year=%s&page=%s' % (season, year, str(page + 1)), None, None) tools.closeDirectory('tvshows')
def main_menu(self): if self.last_watched: self.add_last_watched() if self.kitsu_access or self.mal_access or self.ani_access: tools.addDirectoryItem('My Accounts', 'my_accounts_test', {'plot': 'Explore your account lists from Kitsu, MyAnimeList and AniList.', 'description': 'Explore your account lists from Kitsu, MyAnimeList and AniList.'}, {'poster': os.path.join(tools.ACCOUNTS_PATH, 'account.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Explore Anime...', 'explore_anime', {'plot': 'Explore anime on Kitsu.', 'description': 'Explore anime on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'explore_anime.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Search', 'title_search', {'plot': 'Search anime by title on Kitsu.', 'description': 'Search anime by title on Kitsu.'}, {'poster': os.path.join(tools.OTHER_PATH, 'search.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Advanced Search', 'advanced_search', {'plot': 'Search anime on Kitsu.', 'description': 'Search anime on Kitsu.'}, {'poster': os.path.join(tools.OTHER_PATH, 'advanced_search.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Settings', 'settings', {'plot': 'Adjust the settings.', 'description': 'Adjust the settings.'}, {'poster': os.path.join(tools.OTHER_PATH, 'settings.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.closeDirectory('tvshows')
def rating_list(self): ratings = [ {'name': 'General Audiences', 'slug': 'G'}, {'name': 'Parental Guidence', 'slug': 'PG'}, {'name': 'Restricted', 'slug': 'R'} ] tools.addDirectoryItem('Multi Select...', 'rating_get', None, None) for a in ratings: tools.addDirectoryItem(a['name'], 'rating_get&rating=%s' % a['slug'], None, None) tools.closeDirectory('addons')
def exploreAnime(self): tools.addDirectoryItem('Trending', 'trending', {'plot': 'Explore trending anime on Kitsu.', 'description': 'Explore trending anime on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'trending.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Currently Airing', 'airing', {'plot': 'Explore currently airing anime on Kitsu.', 'description': 'Explore currently airing anime on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'currently_airing.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Upcoming', 'upcoming', {'plot': 'Explore upcoming anime on Kitsu.', 'description': 'Explore upcoming anime on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'upcoming.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Most Popular', 'most_popular', {'plot': 'Explore the most popular anime on Kitsu.', 'description': 'Explore the most popular anime on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'most_popular.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Highest Rated', 'highest_rated', {'plot': 'Explore the highest rated anime on Kitsu.', 'description': 'Explore the highest rated anime on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'highest_rated.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('By Season', 'season', {'plot': 'Explore anime by specific season on Kitsu.', 'description': 'Explore anime by specific season on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'by_season.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Genres', 'genre_search', {'plot': 'Explore anime by genre on Kitsu.', 'description': 'Explore anime by genre on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'genres.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Years', 'year_search', {'plot': 'Explore anime by year on Kitsu.', 'description': 'Explore anime by year on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'years.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Subtypes', 'subtype_search', {'plot': 'Explore anime by subtype on Kitsu.', 'description': 'Explore anime by subtype on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'subtypes.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Seasons', 'season_search', {'plot': 'Explore anime by seasons on Kitsu.', 'description': 'Explore anime by seasons on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'seasons.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.addDirectoryItem('Ratings', 'rating_search', {'plot': 'Explore anime by age ratings on Kitsu.', 'description': 'Explore anime by age ratings on Kitsu.'}, {'poster': os.path.join(tools.BASIC_PATH, 'ratings.png'), 'fanart': os.path.join(tools.MEDIA_PATH, 'fanart.jpg')}) tools.closeDirectory('tvshows')
def season_list(self): seasons = [ {'name': 'Winter', 'slug': 'winter'}, {'name': 'Spring', 'slug': 'spring'}, {'name': 'Summer', 'slug': 'summer'}, {'name': 'Fall', 'slug': 'fall'} ] tools.addDirectoryItem('Multi Select...', 'season_get', None, None) for a in seasons: tools.addDirectoryItem(a['name'], 'season_get&season=%s' % a['slug'], None, None) tools.closeDirectory('addons')
def season_menu(self): from datetime import datetime year = int(datetime.today().year) month = int(datetime.today().month) day = int(datetime.today().day) if month == 1 or month == 2 or month == 3: season = 'Winter' elif month == 4 or month == 5 or month == 6: season = 'Spring' elif month == 7 or month == 8 or month == 9: season = 'Summer' elif month == 10 or month == 11 or month == 12: season = 'Fall' dec_seasons = ['Fall', 'Summer', 'Spring', 'Winter'] seasons_so_far = [] if season == 'Winter': seasons_so_far.append('Winter') elif season == 'Spring': seasons_so_far.append('Spring') seasons_so_far.append('Winter') elif season == 'Summer': seasons_so_far.append('Summer') seasons_so_far.append('Spring') seasons_so_far.append('Winter') elif season == 'Fall': seasons_so_far.append('Fall') seasons_so_far.append('Summer') seasons_so_far.append('Spring') seasons_so_far.append('Winter') years = [] for i in range(1980, year): years.append(i) years = sorted(years, reverse=True) for a in seasons_so_far: meme_material = {'plot': 'Explore anime from %s %s.' % (a, year), 'description': 'Explore anime from %s %s.' % (a, year)} tools.addDirectoryItem('%s %s' % (a, year), 'top_by_season&season=%s&year=%s' % (a.lower(), year), meme_material, None) for a in years: for b in dec_seasons: meme_material = {'plot': 'Explore anime from %s %s.' % (b, a), 'description': 'Explore anime from %s %s.' % (b, a)} tools.addDirectoryItem('%s %s' % (b, a), 'top_by_season&season=%s&year=%s' % (b.lower(), a), meme_material, None) tools.closeDirectory('tvshows')
def year_list(self): from datetime import datetime year = int(datetime.today().year) years = [] for a in range(1907, year + 1): years.append(a) years = sorted(years, reverse=True) #ORIGINALLY HAD MULTI SELECT FOR YEARS, DIDNT WORK EVEN THOUGH API DOCS SAID IT WOULD :S #tools.addDirectoryItem('Multi Select...', 'year_get', None, None) for a in years: tools.addDirectoryItem(str(a), 'year_get&year=%s' % str(a), None, None) tools.closeDirectory('addons')
def title_search(self, query, page): if query is None: k = tools.showKeyboard('', 'Search Anime') k.doModal() search_query = (k.getText() if k.isConfirmed() else None) if search_query == None or query == '': return else: search_query = query anime = kitsu_api.KitsuBrowser().search(title=search_query, subtype='TV,movie,ova,ona,special', page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'title_search&title=%s&page=%s' % (search_query, str(page+1)), None, None) tools.closeDirectory('tvshows')
def advanced_search(self, year, rating, season, subtype, genre, page): items_preselect = ['Years', 'Ratings', 'Seasons', 'Subtypes', 'Genres'] items_selected = ['Years', 'Ratings', 'Seasons', 'Subtypes', 'Genres', 'Search'] years = [] ratings = [] seasons = [] subtypes = [] genres = [] select = '' year_string = year rating_string = rating season_string = season subtype_string = subtype genre_string = genre if year is None and rating is None and season is None and subtype is None and genre is None: while select != 'Search': if years == [] and ratings == [] and seasons == [] and subtypes == [] and genres == []: select_area = tools.showDialog.select(tools.addonName + ': Advanced Search', items_preselect) else: select_area = tools.showDialog.select(tools.addonName + ': Advanced Search', items_selected) if select_area == -1: return select = items_selected[select_area] if select == 'Years': if years != []: years = [] from datetime import datetime adv_year = int(datetime.today().year) adv_years = [] for a in range(1907, adv_year + 1): adv_years.append(str(a)) adv_years = sorted(adv_years, reverse=True) adv_select = tools.showDialog.select(tools.addonName + ': Year Selection', adv_years) if adv_select is None or adv_select == -1: continue years.append(adv_years[adv_select]) if select == 'Ratings': if ratings != []: ratings = [] adv_ratings = [ {'name': 'General Audiences', 'slug': 'G'}, {'name': 'Parental Guidence', 'slug': 'PG'}, {'name': 'Restricted', 'slug': 'R'} ] rating_display_list = [] for a in adv_ratings: rating_display_list.append(a['name']) rating_multiselect = tools.showDialog.multiselect(tools.addonName + ": Rating Selection", rating_display_list) if rating_multiselect is None: continue rating_selection = [] for selection in rating_multiselect: rating_selection.append(adv_ratings[selection]['slug']) ratings=rating_selection if select == 'Seasons': if seasons != []: seasons = [] adv_seasons = [ {'name': 'Winter', 'slug': 'winter'}, {'name': 'Spring', 'slug': 'spring'}, {'name': 'Summer', 'slug': 'summer'}, {'name': 'Fall', 'slug': 'fall'} ] season_display_list = [] for a in adv_seasons: season_display_list.append(a['name']) season_multiselect = tools.showDialog.multiselect(tools.addonName + ": Season Selection", season_display_list) if season_multiselect is None: continue season_selection = [] for selection in season_multiselect: season_selection.append(adv_seasons[selection]['slug']) seasons = season_selection if select == 'Subtypes': if subtypes != []: subtypes = [] adv_subtypes = [ {'name': 'TV Shows', 'slug': 'tv'}, {'name': 'Movies', 'slug': 'movie'}, {'name': 'OVA', 'slug': 'ova'}, {'name': 'ONA', 'slug': 'ona'}, {'name': 'Specials', 'slug': 'special'} ] subtype_display_list = [] for a in adv_subtypes: subtype_display_list.append(a['name']) subtype_multiselect = tools.showDialog.multiselect(tools.addonName + ": Subtype Selection", subtype_display_list) if subtype_multiselect is None: continue subtype_selection = [] for selection in subtype_multiselect: subtype_selection.append(adv_subtypes[selection]['slug']) subtypes = subtype_selection if select == 'Genres': if genres != []: genres = [] from resources.lib.modules import kitsu_api adv_genres = kitsu_api.KitsuBrowser().all_categories() adv_genres = sorted(adv_genres, key= lambda a: (a['name'])) genre_display_list = [] for a in adv_genres: genre_display_list.append(a['name']) genre_multiselect = tools.showDialog.multiselect(tools.addonName + ": Genre Selection", genre_display_list) if genre_multiselect is None: continue genre_selection = [] for selection in genre_multiselect: genre_selection.append(adv_genres[selection]['slug']) genres = genre_selection year_string = ','.join(years) rating_string = ','.join(ratings) season_string = ','.join(seasons) subtype_string = ','.join(subtypes) genre_string = ','.join(genres) from resources.lib.modules import kitsu_api anime = kitsu_api.KitsuBrowser().search(title='', year=year_string, rating=rating_string, season=season_string, subtype=subtype_string, genre=genre_string, page=page) self.list_builder(anime) if len(anime) == 20: tools.addDirectoryItem('Next Page...', 'advanced_search&year=%s&rating=%s&season=%s&subtype=%s&genre=%s&page=%s' % (year_string, rating_string, season_string, subtype_string, genre_string, str(page+1)), None, None) tools.closeDirectory('tvshows')
def trending(self): anime = kitsu_api.KitsuBrowser().trending() self.list_builder(anime) tools.closeDirectory('tvshows')
def episode_list(self, args, page, progress): show_info = json.loads(tools.unquote(args)) episodes = kitsu_api.KitsuBrowser().all_episodes(id=show_info['id']) self.episode_list_builder(show_info, episodes, progress) tools.closeDirectory('episodes')
def get_list(self, site, list): from resources.lib.modules import accounts anime = accounts.Lists().get(site, list) self.list_builder(anime) tools.closeDirectory('tvshows')