Example #1
0
        public static Anime AnimeCons(AnimeListEntry entry, Jikan jikan)
        {
            var anime = new Anime(entry);

            JikanDotNet.Anime _anime = jikan.GetAnime(anime.MalId).Result;
            return(anime);
        }
        public async Task <IActionResult> Index(long id)
        {
            AnimeDetailsModel model = new AnimeDetailsModel();

            Jikan jikan = new Jikan();

            var anime = await jikan.GetAnime(id);

            model.ID           = anime.MalId;
            model.Title        = anime.Title;
            model.EnglishTitle = anime.TitleEnglish;
            model.Studios      = string.Join(", ", anime.Studios);
            model.Synopsis     = anime.Synopsis;
            model.ImageURL     = anime.ImageURL;
            model.Genres       = string.Join(", ", anime.Genres);
            model.Airing       = anime.Airing;
            model.Premiered    = anime.Premiered;

            int episodes;

            if (!int.TryParse(anime.Episodes, out episodes))
            {
                episodes = -1;
            }
            model.Episodes = episodes;

            return(View("AnimeDetailsView", model));
        }
        public async Task JikanConstructor_WrongUrl_ShouldNotParseCorrectly()
        {
            IJikan jikan = new Jikan("http://google.com");

            Anime bebop = await jikan.GetAnime(1);

            Assert.Null(bebop);
        }
        public async Task JikanConstructor_CustomUrl_ShouldParseCorrectly()
        {
            IJikan jikan = new Jikan("https://seiyuu.moe:8000/v3/");

            Anime bebop = await jikan.GetAnime(1);

            Assert.Equal(1, bebop.MalId);
        }
        public async Task JikanConstructor_DefaultUrl_ShouldParseCorrectly()
        {
            IJikan jikan = new Jikan("https://api.jikan.moe/v3/");

            Anime bebop = await jikan.GetAnime(1);

            Assert.Equal(1, bebop.MalId);
        }
Example #6
0
        public async Task JikanConstructor_DefaultUrl_ShouldParseCorrectly()
        {
            // Given
            IJikan jikan = new Jikan("https://api.jikan.moe/v3/");

            // When
            Anime bebop = await jikan.GetAnime(1);

            // Then
            bebop.MalId.Should().Be(1);
        }
Example #7
0
        public async Task JikanConstructor_CustomUrl_ShouldParseCorrectly()
        {
            // Given
            IJikan jikan = new Jikan("https://seiyuu.moe:8000/v3/");

            // When
            Anime bebop = await jikan.GetAnime(1);

            // Then
            bebop.MalId.Should().Be(1);
        }
Example #8
0
        public async Task JikanConstructorHttpClient_CorrectConfiguration_ShouldParseCorrectly()
        {
            // Given
            var httpClient = new HttpClient
            {
                BaseAddress = new Uri("https://seiyuu.moe:8000/v3/")
            };
            var jikan = new Jikan(httpClient, false);

            // When
            Anime bebop = await jikan.GetAnime(1);

            // Then
            bebop.MalId.Should().Be(1);
        }
Example #9
0
        public async void getAnime()
        {
            IJikan jikan = new Jikan();

            try
            {
                Anime res = await jikan.GetAnime(1);

                this.DataContext = new TextBoxText()
                {
                    textData = res.Title
                };
            }
            catch (Exception e) {
                Console.Out.WriteLine(e.Message);
            }
        }
Example #10
0
        public async Task SuggestAnime(CommandContext ctx)
        {
            IJikan jikan = new Jikan();

            JikanDotNet.Anime RandomAnime = null;
            int AnimeID = 0;

            Console.WriteLine("SuggestAnime");
            do
            {
                AnimeID = getRandom();

                Task <JikanDotNet.Anime> task = jikan.GetAnime(AnimeID);
                Task continutation            = task.ContinueWith(t =>
                {
                    Console.WriteLine("Result : " + t.Result);
                    RandomAnime = t.Result;
                });
                continutation.Wait();
            } while (Object.ReferenceEquals(null, RandomAnime));


            string Desc = "Episodes :tv:        : {0}\n\n" +
                          "Duration :clock1:    : {1}\n\n" +
                          "Score    :star:      : {2}\n\n" +
                          "Rating   :underage:  : {3}\n";


            var AnimeDesc = string.Format(Desc, RandomAnime.Episodes,
                                          RandomAnime.Duration, RandomAnime.Score, RandomAnime.Rating);


            var embed = new DiscordEmbedBuilder
            {
                Title       = RandomAnime.Title,
                Description = AnimeDesc,
                ImageUrl    = RandomAnime.ImageURL,
            };

            await ctx.RespondAsync(ctx.User.Mention, embed : embed);
        }
Example #11
0
        public IActionResult Index()
        {
            if (User.Identity.IsAuthenticated)
            {
                Jikan jikan = new Jikan();

                var userId          = User.FindFirstValue(ClaimTypes.NameIdentifier);
                var userAnimeLabels = _dbContext.UserAnimeLabels
                                      .Where(x => x.UserId == userId)
                                      .Include(x => x.Label)
                                      .Select(x => new LabeledAnime
                {
                    LabelName = x.Label.Name,
                    AnimeName = jikan.GetAnime(x.AnimeId).Result.Title
                })
                                      .ToList();

                var temp = userAnimeLabels.GroupBy(x => x.LabelName);
                ViewData["LikedAnime"] = userAnimeLabels.GroupBy(x => x.LabelName);
            }

            return(View());
        }
        public async Task JikanConstructorUri_WrongUrlNoSurpress_ShouldThrowJikanException()
        {
            IJikan jikan = new Jikan(new Uri("http://google.com"), false);

            await Assert.ThrowsAsync <JikanRequestException>(() => jikan.GetAnime(1));
        }
Example #13
0
        static void Main(string[] args)
        {
            // Initialize JikanWrapper
            IJikan jikan = new Jikan(true);

            // Send request for "Cowboy Bebop" anime
            Anime cowboyBebop = jikan.GetAnime(1).Result;

            // Output -> "Cowboy Bebop"
            Console.WriteLine(cowboyBebop.Title);
            // Output -> "TV"
            Console.WriteLine(cowboyBebop.Type);
            // Output -> "R - 17+ (violence & profanity)"
            Console.WriteLine(cowboyBebop.Rating);


            // Send request for episodes of "Cowboy Bebop" anime
            AnimeEpisodes episodes = jikan.GetAnimeEpisodes(1).Result;

            // Output -> "1"
            Console.WriteLine("Last page: " + episodes.EpisodesLastPage);

            // Print number and English title of each episode
            foreach (AnimeEpisode episode in episodes.EpisodeCollection)
            {
                Console.WriteLine("Episode " + episode.Id + ", English title: " + episode.Title);
            }

            // Send request for episodes of "One Piece" anime -> loads data of episodes from 1 to 100
            AnimeEpisodes onePieceEpisodes = jikan.GetAnimeEpisodes(21).Result;

            // Send request for episodes of "One Piece" anime -> loads data of episodes from 1 to 100
            onePieceEpisodes = jikan.GetAnimeEpisodes(21, 1).Result;

            // Send request for episodes of "One Piece" anime -> loads data of episodes from 101 to 200
            onePieceEpisodes = jikan.GetAnimeEpisodes(21, 2).Result;

            // Send request for "Berserk" manga
            Manga berserkManga = jikan.GetManga(2).Result;

            // Output -> "Berserk"
            Console.WriteLine(berserkManga.Title);
            // Output -> "Publishing"
            Console.WriteLine(berserkManga.Status);

            // Send request for episodes of "Cowboy Bebop" staff and members
            AnimeCharactersStaff charactersStaff = jikan.GetAnimeCharactersStaff(1).Result;

            // Print all characters names and their role (main or supporting).
            foreach (var character in charactersStaff.Characters)
            {
                Console.WriteLine(character.Name + " (" + character.Role + ")");
            }

            // Print all staff members names and their position during production.
            foreach (var staffMember in charactersStaff.Staff)
            {
                Console.WriteLine(staffMember.Name + " (" + String.Join(", ", staffMember.Role) + ")");
            }

            // Send request for pictures of "Cowboy Bebop"
            AnimePictures pictures = jikan.GetAnimePictures(1).Result;

            // Print link to every picture.
            foreach (Picture picture in pictures.Pictures)
            {
                Console.WriteLine(picture.Large);;
            }

            // Send request for episodes of "Cowboy Bebop" pictures
            AnimeNews news = jikan.GetAnimeNews(1).Result;

            // Print date of each news
            foreach (News newsEntry in news.News)
            {
                Console.WriteLine(newsEntry.Date);
            }

            // Send request for videos of "Cowboy Bebop"
            AnimeVideos videos = jikan.GetAnimeVideos(1).Result;

            // Print each episode video title
            foreach (var episode in videos.EpisodeVideos)
            {
                Console.WriteLine("Episode " + episode.NumberedTitle + ": " + episode.Title);
            }

            // Print each promo video title
            foreach (var promo in videos.PromoVideos)
            {
                Console.WriteLine(promo.Title);
            }

            // Send request for statistics of "Cowboy Bebop"
            AnimeStats stats = jikan.GetAnimeStatistics(1).Result;

            // Print statistics to output.
            Console.WriteLine("Comppleted by " + stats.Completed + " users");
            Console.WriteLine("Being watched by " + stats.Watching + " users");
            Console.WriteLine("Dropped by " + stats.Dropped + " users");

            // Send request for forum topics of "Cowboy Bebop"
            ForumTopics forumTopics = jikan.GetAnimeForumTopics(1).Result;

            // Post each topic title and date of creation
            foreach (var topic in forumTopics.Topics)
            {
                Console.WriteLine(topic.Title + ", created:" + topic.DatePosted);
            }

            // Send request for more info of "Cowboy Bebop"
            MoreInfo moreInfo = jikan.GetAnimeMoreInfo(1).Result;

            // Output -> "Suggested Order..."
            Console.WriteLine("Additional info:" + moreInfo.Info);

            // Send request for pictures of "Berserk" manga.
            MangaPictures berserkPics = jikan.GetMangaPictures(2).Result;

            // Print link to every picture.
            foreach (Picture picture in pictures.Pictures)
            {
                Console.WriteLine(picture.Large);;
            }

            // Send request for "Berserk" characters
            MangaCharacters berserkCharacters = jikan.GetMangaCharacters(1).Result;

            // Print all characters names and their role (main or supporting).
            foreach (var character in berserkCharacters.Characters)
            {
                Console.WriteLine(character.Name + " (" + character.Role + ")");
            }

            // Send request for "Berserk" news
            MangaNews berserjNews = jikan.GetMangaNews(2).Result;

            // Print date of each news
            foreach (News newsEntry in news.News)
            {
                Console.WriteLine(newsEntry.Date);
            }

            // Send request for statistics of "Berserk" manga
            MangaStats berserkStats = jikan.GetMangaStatistics(2).Result;

            // Print statistics to output.
            Console.WriteLine("Completed by " + berserkStats.Completed + " users");
            Console.WriteLine("Being read by " + berserkStats.Reading + " users");
            Console.WriteLine("Dropped by " + berserkStats.Dropped + " users");

            // Send request for forum topics of "Berserk" manga.
            ForumTopics bersekrForumTopics = jikan.GetMangaForumTopics(2).Result;

            // Post each topic title and date of creation
            foreach (var topic in bersekrForumTopics.Topics)
            {
                Console.WriteLine(topic.Title + ", created:" + topic.DatePosted);
            }

            // Send request for more info of "Berserk" manga.
            MoreInfo berserkMoreInfo = jikan.GetMangaMoreInfo(2).Result;

            // Output -> "Berserk: The Prototype (1988)"
            Console.WriteLine("Additional info:" + moreInfo.Info);

            // Send request for Hayao Miyazaki
            Person hayaoMiyazaki = jikan.GetPerson(1870).Result;

            // List Miyazaki anime on output
            foreach (var staffPosition in hayaoMiyazaki.AnimeStaffPositions)
            {
                Console.WriteLine("Anime: " + staffPosition.Anime.Name + ", role: " + staffPosition.Position);
            }

            // Send request for pictures of Hayao Miyazaki.
            PersonPictures hayaoMiyazakiPics = jikan.GetPersonPictures(1870).Result;

            // Print link to every picture.
            foreach (Picture picture in hayaoMiyazakiPics.Pictures)
            {
                Console.WriteLine(picture.Large);;
            }

            // Send request for Lain Iwakura
            Character lainIwakura = jikan.GetCharacter(2219).Result;

            // List Lain's voice actresses with their respective languages
            foreach (var voiceActor in lainIwakura.VoiceActors)
            {
                Console.WriteLine("Name: " + voiceActor.Name + ", language: " + voiceActor.Language);
            }

            // List all anime in which Lain appeared
            foreach (var anime in lainIwakura.Animeography)
            {
                Console.WriteLine("Title: " + anime.Name);
            }

            // Send request for pictures of Spike Spiegel.
            CharacterPictures spikePics = jikan.GetCharacterPictures(1).Result;

            // Print link to every picture.
            foreach (Picture picture in spikePics.Pictures)
            {
                Console.WriteLine(picture.Large);;
            }

            // Send request for current season.
            Season season = jikan.GetSeason().Result;

            // Print season basic information
            Console.WriteLine("Season : " + season.SeasonYear + " " + season.SeasonName);

            // Print each anime title of the season.
            foreach (var seasonEntry in season.SeasonEntries)
            {
                Console.WriteLine(seasonEntry.Title);
            }

            // Send request for Fall 2010
            season = jikan.GetSeason(2010, Seasons.Fall).Result;

            // Send request for season archives
            SeasonArchives seasonArchive = jikan.GetSeasonArchive().Result;

            // Print all available years with their available seasons
            foreach (var archive in seasonArchive.Archives)
            {
                Console.WriteLine("Year: " + archive.Year + ", available seasons: " + string.Join(", ", archive.Season));
            }

            // Send request for schedule
            Schedule schedule = jikan.GetSchedule().Result;

            // Print title of each anime airing on monday
            foreach (var mondayAnime in schedule.Monday)
            {
                Console.WriteLine(mondayAnime.Title);
            }

            // Print title of each anime with irregular airing cycle.
            foreach (var other in schedule.Other)
            {
                Console.WriteLine(other.Title);
            }

            // Send request for Sunday schedule
            schedule = jikan.GetSchedule(ScheduledDay.Sunday).Result;

            // Print title of each anime airing on monday
            foreach (var sundayAnime in schedule.Sunday)
            {
                Console.WriteLine(sundayAnime.Title);
            }

            // Will throw Exception -> schedule.Monday is null!
            foreach (var mondayAnime in schedule.Monday)
            {
                Console.WriteLine(mondayAnime.Title);
            }

            // Send request for anime ranking (highest rating).
            AnimeTop topAnimeList = jikan.GetAnimeTop().Result;

            // Print title of each anime in the top 50
            foreach (var listEntry in topAnimeList.Top)
            {
                Console.WriteLine(listEntry.Title);
            }

            // Send request for second page (positions 51-100) of anime with highest ratings.
            topAnimeList = jikan.GetAnimeTop(2).Result;

            // Send request for anime with highest ratings currently airing.
            topAnimeList = jikan.GetAnimeTop(TopAnimeExtension.TopAiring).Result;

            // Send request for second page of most popular anime.
            topAnimeList = jikan.GetAnimeTop(2, TopAnimeExtension.TopPopularity).Result;


            // Send request for manga ranking (highest rating).
            MangaTop topMangaList = jikan.GetMangaTop().Result;

            // Print title of each manga in the top 50
            foreach (var listEntry in topMangaList.Top)
            {
                Console.WriteLine(listEntry.Title);
            }

            // Send request for second page (positions 51-100) of manga with highest ratings.
            topMangaList = jikan.GetMangaTop(2).Result;

            // Send request for light novels with highest ratings.
            topMangaList = jikan.GetMangaTop(TopMangaExtension.TopNovel).Result;

            // Send request for second page of most popular manga.
            topMangaList = jikan.GetMangaTop(2, TopMangaExtension.TopPopularity).Result;

            // Send request for most popular people on MAL
            PeopleTop topPeopleList = jikan.GetPeopleTop().Result;

            // Print rank and name of each person in top 50.
            foreach (var listEntry in topPeopleList.Top)
            {
                Console.WriteLine(listEntry.Rank + ". " + listEntry.Name);
            }

            // Send request for second page (positions 51 - 100) of most popular people
            topPeopleList = jikan.GetPeopleTop(2).Result;

            // Send request for most popular characters on MAL
            CharactersTop topCharacterList = jikan.GetCharactersTop().Result;

            // Print rank and name of each character in top 50.
            foreach (var listEntry in topCharacterList.Top)
            {
                Console.WriteLine(listEntry.Rank + ". " + listEntry.Name);
            }

            // Send request for second page (positions 51 - 100) of most popular characters.
            topCharacterList = jikan.GetCharactersTop(2).Result;

            // Send request for mecha genre (and first 100 mecha anime snippets)
            AnimeGenre animeGenre = jikan.GetAnimeGenre(18).Result;

            // Output -> "Mecha"
            Console.WriteLine(animeGenre.Metadata.Name);

            // Print title of each of the first 100 mecha anime
            foreach (var anime in animeGenre.Anime)
            {
                Console.WriteLine(anime.Title);
            }

            // Send request for mecha genre (mecha anime snippets on positions 101-200)
            animeGenre = jikan.GetAnimeGenre(18, 2).Result;

            // Send request for samurai anime genre (and first 100 samurai anime snippets)
            animeGenre = jikan.GetAnimeGenre(GenreSearch.Samurai).Result;

            // Send request for sports genre (sports anime snippets on positions 201-300)
            animeGenre = jikan.GetAnimeGenre(GenreSearch.Sports, 3).Result;

            // Send request for mecha genre (and first 100 mecha manga snippets)
            MangaGenre mangaGenre = jikan.GetMangaGenre(18).Result;

            // Output -> "Mecha"
            Console.WriteLine(mangaGenre.Metadata.Name);

            // Print title of each of the first 100 mecha manga
            foreach (var anime in mangaGenre.Manga)
            {
                Console.WriteLine(anime.Title);
            }

            // Send request for mecha genre (mecha manga snippets on positions 101-200)
            mangaGenre = jikan.GetMangaGenre(18, 2).Result;

            // Send request for samurai manga genre (and first 100 samurai manga snippets)
            mangaGenre = jikan.GetMangaGenre(GenreSearch.Samurai).Result;

            // Send request for sports genre (sports manga snippets on positions 201-300)
            mangaGenre = jikan.GetMangaGenre(GenreSearch.Sports, 3).Result;

            // Send request for KyotoAnimation
            Producer producer = jikan.GetProducer(2).Result;

            // Output -> "Kyoto Animation"
            Console.WriteLine(producer.Metadata.Name);

            // Print title of each anime of the first 100 anime made by Kyoto Animation
            foreach (var anime in producer.Anime)
            {
                Console.WriteLine(anime.Title);
            }

            // Send request for "Studio Pierrot" (and their anime listed on positions 101-200)
            producer = jikan.GetProducer(1, 2).Result;

            // Send request for "Young Animal" magazine.
            Magazine magazine = jikan.GetMagazine(2).Result;

            // Output -> "Young Animal"
            Console.WriteLine(magazine.Metadata.Name);

            // Print title of each manga of the first 100 mangas of "Young Animal"
            foreach (var manga in magazine.Manga)
            {
                Console.WriteLine(manga.Title);
            }

            // Send request for "Shonen Jump" (and their manga listed on positions 101-200)
            magazine = jikan.GetMagazine(83, 2).Result;

            UserProfile profile = jikan.GetUserProfile("Ervelan").Result;

            // Output -> "Male"
            Console.WriteLine(profile.Gender);

            // Print name of each favorite character
            foreach (var favoriteCharacter in profile.Favorites.Characters)
            {
                Console.WriteLine(favoriteCharacter.Name);
            }

            // Print information about completed and watching/reading anime/manga.
            Console.WriteLine("Completed " + profile.AnimeStatistics.Completed + " anime and " + profile.MangaStatistics.Completed + " manga.");
            Console.WriteLine("Currently watching " + profile.AnimeStatistics.Watching + " anime and reading " + profile.MangaStatistics.Reading + " manga.");

            // Send request for history of user "Ervelan"
            UserHistory userHistory = jikan.GetUserHistory("Ervelan").Result;

            // Print title of each anime/manga and related incerement.
            foreach (var historyEntry in userHistory.History)
            {
                Console.WriteLine(historyEntry.Metadata.Name + ": " + historyEntry.Increment);
            }

            // Send request for friend list of user "Ervelan"
            UserFriends friends = jikan.GetUserFriends("Ervelan").Result;

            // Print each friend username with their last online activity date.
            foreach (var friend in friends.Friends)
            {
                Console.WriteLine(friend.Username + " last seen online " + friend.LastOnline);
            }

            // Send request for friend list of user "batsling1234" on positions 101-200 (sorted by most recent online activity).
            friends = jikan.GetUserFriends("batsling1234", 2).Result;

            // Send request for anime list of user with "Ervelan" username (first 300 entries)
            UserAnimeList animeList = jikan.GetUserAnimeList("Ervelan").Result;

            // Print first 300 anime on requested list wiht scores assigned by user.
            foreach (var anime in animeList.Anime)
            {
                Console.WriteLine("Title: " + anime.Title + ", " + anime.Score);
            }

            // Send request for anime list of user with "Ervelan" username (entries from position 301 to 600).
            animeList = jikan.GetUserAnimeList("Ervelan", 2).Result;

            // Send request for anime list of user with "Ervelan" username (dropped anime only).
            animeList = jikan.GetUserAnimeList("Ervelan", UserAnimeListExtension.Dropped).Result;


            // Send request for anime list of user with "Ervelan" username (completed anime only, from position 301 to 600).
            animeList = jikan.GetUserAnimeList("Ervelan", UserAnimeListExtension.Completed, 2).Result;

            // Send request for manga list of user with "SonMati" username (first 300 entries)
            UserMangaList mangalist = jikan.GetUserMangaList("SonMati").Result;

            // Print first 300 manga on requested list wiht scores assigned by user.
            foreach (var manga in mangalist.Manga)
            {
                Console.WriteLine("Title: " + manga.Title + ", " + manga.Score);
            }

            // Send request for manga list of user with "SonMati" username (entries from position 301 to 600).
            mangalist = jikan.GetUserMangaList("SonMati", 2).Result;

            // Send request for manga list of user with "SonMati" username (reading manga only).
            mangalist = jikan.GetUserMangaList("SonMati", UserMangaListExtension.Reading).Result;

            // Send request for manga list of user with "SonMati" username (completed manga only, from position 301 to 600).
            mangalist = jikan.GetUserMangaList("SonMati", UserMangaListExtension.Completed, 2).Result;

            // Send request to search anime with "haibane" key word
            AnimeSearchResult animeSearchResult = jikan.SearchAnime("haibane").Result;

            // Print title of the first result
            // Output -> "Haibane Renmei"
            Console.WriteLine(animeSearchResult.Results.First().Title);

            // Send request to search anime with "gundam" key word, second page of results
            animeSearchResult = jikan.SearchAnime("gundam", 2).Result;

            AnimeSearchConfig animeSearchConfig = new AnimeSearchConfig()
            {
                Type  = AnimeType.Movie,
                Score = 7
            };

            // Send request to search anime with "gundam" key word, movies with score bigger than 7 only.
            animeSearchResult = jikan.SearchAnime("gundam", animeSearchConfig).Result;

            animeSearchConfig = new AnimeSearchConfig()
            {
                Genres        = { GenreSearch.Action, GenreSearch.Adventure },
                GenreIncluded = true
            };

            // Send request to search anime with "samurai" key word, with action and/or adventure genre.
            animeSearchResult = jikan.SearchAnime("samurai", animeSearchConfig).Result;

            animeSearchConfig = new AnimeSearchConfig()
            {
                Genres        = { GenreSearch.Mecha, GenreSearch.Romance },
                GenreIncluded = false
            };

            // Send request to search anime with "samurai" key word, without mecha and/or romance genre.
            animeSearchResult = jikan.SearchAnime("samurai", animeSearchConfig).Result;

            animeSearchConfig = new AnimeSearchConfig()
            {
                Rating = AgeRating.RX
            };

            // Send request to search anime with "xxx" key word, adult anime only, second page of results
            animeSearchResult = jikan.SearchAnime("xxx", 2, animeSearchConfig).Result;

            // Send request to search manga with "berserk" key word
            MangaSearchResult mangaSearchResult = jikan.SearchManga("berserk").Result;

            // Print title of the first result
            // Output -> "Berserk"
            Console.WriteLine(mangaSearchResult.Results.First().Title);

            // Send request to search manga with "gundam" key word, second page of results
            mangaSearchResult = jikan.SearchManga("gundam", 2).Result;

            MangaSearchConfig mangaSearchConfig = new MangaSearchConfig()
            {
                Type  = MangaType.Novel,
                Score = 5
            };

            // Send request to search manga with "gundam" key word, novel/light novel with score bigger than 5 only.
            mangaSearchResult = jikan.SearchManga("gundam", mangaSearchConfig).Result;

            mangaSearchConfig = new MangaSearchConfig()
            {
                Genres        = { GenreSearch.Mecha, GenreSearch.Adventure },
                GenreIncluded = true
            };

            // Send request to search manga with "samurai" key word, with Mecha and/or adventure genre.
            mangaSearchResult = jikan.SearchManga("samurai", mangaSearchConfig).Result;

            mangaSearchConfig = new MangaSearchConfig()
            {
                Genres        = { GenreSearch.Ecchi, GenreSearch.Game },
                GenreIncluded = false
            };

            // Send request to search manga with "samurai" key word, without ecchi and/or game genre.
            mangaSearchResult = jikan.SearchManga("samurai", mangaSearchConfig).Result;

            mangaSearchConfig = new MangaSearchConfig()
            {
                Rating = AgeRating.RX
            };

            // Send request to search manga with "xxx" key word, adult anime only, second page of results
            mangaSearchResult = jikan.SearchManga("xxx", 2, mangaSearchConfig).Result;

            // Send request to search person with "sawashiro" key word
            PersonSearchResult personSearchResult = jikan.SearchPerson("sawashiro").Result;

            // Print name of the first result
            // Output -> "Miyuki Sawashiro"
            Console.WriteLine(personSearchResult.Results.First().Name);

            // Send request to search person with "sawashiro" key word, second page (positions 51-100)
            personSearchResult = jikan.SearchPerson("sawashiro", 2).Result;

            // Send request to search character with "spiegel" key word
            CharacterSearchResult characterSearchResult = jikan.SearchCharacter("spiegel").Result;

            // Print name of the first result
            // Output -> "Spike Spiegel"
            Console.WriteLine(characterSearchResult.Results.First().Name);

            // Send request to search character with "edward" key word, second page (positions 51-100)
            characterSearchResult = jikan.SearchCharacter("edward", 2).Result;

            // Send request for Jikan status metadata.
            StatusMetadata statusMetadata = jikan.GetStatusMetadata().Result;

            // Print amount of today's and weekly requests.
            Console.WriteLine("Today requests:" + statusMetadata.RequestsToday + ", weekly: " + statusMetadata.RequestsThisWeek);
        }
Example #14
0
        public async Task <IActionResult> GetAnimeDetailsFromUserWatchlist(string username, long id)
        {
            Jikan jikan = new Jikan();

            var watchlistData = await jikan.GetUserAnimeList(username);

            Anime             details = null;
            AnimeDetailsModel model   = new AnimeDetailsModel();

            foreach (var anime in watchlistData.Anime)
            {
                var watchStatus = anime.WatchingStatus;

                if (anime.MalId == id)
                {
                    details = await jikan.GetAnime(id);

                    model.ID           = details.MalId;
                    model.Title        = details.Title;
                    model.EnglishTitle = details.TitleEnglish;
                    model.Studios      = string.Join(", ", details.Studios);
                    model.Synopsis     = details.Synopsis;
                    model.ImageURL     = details.ImageURL;
                    model.Genres       = string.Join(", ", details.Genres);
                    model.Airing       = details.Airing;
                    model.Premiered    = details.Premiered;

                    int episodes;
                    if (!int.TryParse(details.Episodes, out episodes))
                    {
                        episodes = -1;
                    }
                    model.Episodes = episodes;

                    if (anime.Score == 0)
                    {
                        model.Score = null;
                    }
                    else
                    {
                        model.Score = anime.Score;
                    }

                    switch (anime.WatchingStatus)
                    {
                    case UserAnimeListExtension.Completed:
                        model.ListStatus = "Completed";
                        break;

                    case UserAnimeListExtension.Dropped:
                        model.ListStatus = "Dropped";
                        break;

                    case UserAnimeListExtension.OnHold:
                        model.ListStatus = "On Hold";
                        break;

                    case UserAnimeListExtension.PlanToWatch:
                        model.ListStatus = "Plan To Watch";
                        break;

                    case UserAnimeListExtension.Watching:
                        model.ListStatus = "Watching";
                        break;

                    default:
                        model.ListStatus = null;
                        break;
                    }

                    break;
                }
            }

            if (details == null)
            {
                // lmao what do?
                return(View(new ErrorViewModel {
                    RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier
                }));
            }



            return(View("Views/Anime/AnimeDetailsView.cshtml", model));
        }
Example #15
0
 public static async Task <Anime> GetAnime(long id)
 {
     return(await Task.Run(() => Jikan.GetAnime(id).Result)); //Gets anime machine
 }
        public void JikanConstructor_WrongUrl_ShouldNotParseCorrectly()
        {
            IJikan jikan = new Jikan("http://google.com");

            Assert.ThrowsAnyAsync <JikanRequestException>(() => jikan.GetAnime(1));
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);

            modelBuilder.Entity <AnimeLabel>().HasKey(x => x.Id);
            modelBuilder.Entity <UserAnimeLabel>().HasKey(x => new { x.UserId, x.AnimeId, x.LabelId });
            modelBuilder.Entity <FriendRelation>().HasKey(e => new { e.UserId, e.FriendId });
            modelBuilder.Entity <Anime>().HasKey(x => x.MalId);
            modelBuilder.Entity <AnimeLabel>().HasKey(x => x.Id);
            modelBuilder.Entity <ScheduledAnime>().HasKey(x => x.Id);

            modelBuilder.Entity <FriendRelation>()
            .HasOne(e => e.User)
            .WithMany(e => e.IAmFriendsWith)
            .HasForeignKey(e => e.UserId)
            .OnDelete(DeleteBehavior.Cascade);

            modelBuilder.Entity <FriendRelation>()
            .HasOne(e => e.Friend)
            .WithMany(e => e.AreFriendsWithMe)
            .HasForeignKey(e => e.FriendId)
            .OnDelete(DeleteBehavior.NoAction);

            modelBuilder.Entity <Anime>()
            .Ignore(x => x.TitleSynonyms)
            .Ignore(x => x.OpeningTheme)
            .Ignore(x => x.EndingTheme)
            .Ignore(x => x.Genres)
            .Ignore(x => x.Licensors)
            .Ignore(x => x.Producers)
            .Ignore(x => x.Studios)
            .Ignore(x => x.Related)
            .Ignore(x => x.Aired);

            modelBuilder.Entity <MALSubItem>().HasKey(x => x.MalId);

            var userEmail = "*****@*****.**";

            modelBuilder.Entity <AppUser>().HasData(
                new AppUser()
            {
                Id                   = "f2bc0937-52d6-4012-bc65-91535266799d",
                UserName             = userEmail,
                NormalizedUserName   = userEmail.ToUpper(),
                Email                = userEmail,
                NormalizedEmail      = userEmail.ToUpper(),
                EmailConfirmed       = true,
                PasswordHash         = "AQAAAAEAACcQAAAAEL6eBpwetmHd6NziWJg86HtmxOyznY2CUyRaYAlGxEdU423LR18jK5rXYu8pCTWpGw==",
                SecurityStamp        = "E4IMYKVLO574KFHY5KLX4YHR46TFGK4O",
                ConcurrencyStamp     = "271801b3-57ba-44f4-a84b-c8d149e691bc",
                AccessFailedCount    = 0,
                PhoneNumberConfirmed = false,
                TwoFactorEnabled     = false,
                LockoutEnabled       = true
            }
                );

            modelBuilder.Entity <AnimeLabel>().HasData(
                new AnimeLabel()
            {
                Id = 1, Name = "Liked"
            },
                new AnimeLabel()
            {
                Id = 2, Name = "Disliked"
            },
                new AnimeLabel()
            {
                Id = 3, Name = "Watched"
            },
                new AnimeLabel()
            {
                Id = 4, Name = "Dropped"
            },
                new AnimeLabel()
            {
                Id = 5, Name = "Won't watch"
            }
                );

            Jikan jikan       = new Jikan();
            var   searchAnime = jikan.SearchAnime("Sekaiichi Hatsukoi").GetAwaiter().GetResult().Results.First();
            var   anime       = jikan.GetAnime(searchAnime.MalId).GetAwaiter().GetResult();
            var   yaoiId      = searchAnime.MalId;

            modelBuilder.Entity <Anime>().HasData(anime);

            modelBuilder.Entity <UserAnimeLabel>().HasData(
                new UserAnimeLabel()
            {
                UserId = "f2bc0937-52d6-4012-bc65-91535266799d", AnimeId = yaoiId, LabelId = 1
            },
                new UserAnimeLabel()
            {
                UserId = "f2bc0937-52d6-4012-bc65-91535266799d", AnimeId = yaoiId, LabelId = 3
            }
                );
        }
Example #18
0
        public async Task AnimeSearchAsync([Optional] params string[] query)
        {
            if (query.Length == 0)
            {
                await ReplyAsync("Kullanım: `b!anime <anime>`");

                return;
            }

            try
            {
                StringBuilder strBuilder = new StringBuilder();
                IJikan        jikan      = new Jikan(true);

                AnimeSearchResult animeSearch = await jikan.SearchAnime(query.ParseText());

                Dictionary <int, AnimeSearchEntry> searchResults = new Dictionary <int, AnimeSearchEntry>();
                int i = 0;
                foreach (var anime in animeSearch.Results)
                {
                    if (i == 10)
                    {
                        break;
                    }
                    strBuilder.Append((i + 1) + " - " + anime.Title)
                    .Append(Environment.NewLine);
                    searchResults.Add(i + 1, anime);
                    i++;
                }

                var prompt = await ReplyAsync($"```{strBuilder.ToString()}```" + Environment.NewLine +
                                              "Yukarıdan seç ve sadece numarayı yaz. Örneğin `3`");

                var timespan = TimeSpan.FromSeconds(10);
                while (timespan != TimeSpan.Zero)
                {
                    if (timespan.TotalSeconds < TimeSpan.FromSeconds(1).TotalSeconds)
                    {
                        break;
                    }

                    var response = await NextMessageAsync();

                    if (response != null)
                    {
                        if (int.TryParse(response.Content, out int intAnime) && intAnime <= 10 && intAnime > 0)
                        {
                            // embed builder to show it bae.
                            var     anime   = jikan.GetAnime(searchResults.GetValueOrDefault(intAnime).MalId).Result;
                            Methods methods = new Methods();
                            await prompt.ModifyAsync(msg =>
                            {
                                msg.Content = "";
                                msg.Embed   = methods.CreateAnimeEmbed(anime, Context.User);
                            });

                            await response.DeleteAsync();

                            return;
                        }
                        else
                        {
                            await ReplyAsync("Zaman aşımı.");

                            return;
                        }
                    }
                }
                return;
            }
            catch (Exception ex)
            {
                await StaticMethods.ExceptionHandler(ex, Context);

                return;
            }
        }