public async Task UserAsync([Remainder] string query) { AnilistClient client = new AnilistClient(); var ch = await client.GetMediaAsync(query, MediaFormat.MANGA, MediaFormat.NOVEL, MediaFormat.ONE_SHOT); int count = 0; string Genres = "Genres: "; string Score = ch.Score.ToString(); while (count < ch.Genres.Count()) { Genres = Genres + ch.Genres[count] + ", "; count++; } Genres = Genres.Remove(Genres.Length - 2); var embed = new EmbedBuilder() { Title = ch.DefaultTitle, Url = ch.Url, Description = Genres + "\n" + "\n" + ch.Episodes + " épisodes" + "\n" + "\n" + ch.Description, ThumbnailUrl = ch.CoverImage, Color = Discord.Color.Red, Footer = new EmbedFooterBuilder() { IconUrl = ch.Url, Text = "AL Score: " + Score + "/100", } }.Build(); await ReplyAsync(Context.User.Mention); await ReplyAsync(embed : embed); }
public async Task UserAsyncc([Remainder] string query) { AnilistClient client = new AnilistClient(); var ch = await client.GetCharacterAsync(query); string id = ch.Id.ToString(); string nom = ch.FirstName + " " + ch.LastName; string Description = string.Empty; if (ch.Description.Length > 2048) { Description = ch.Description.Replace("~!", "||").Replace("!~", "||").Remove(2048); } else { Description = ch.Description.Replace("~!", "||").Replace("!~", "||"); } var embed = new EmbedBuilder() { Title = nom.PadLeft(4, ','), Url = ch.SiteUrl, Description = Description, ThumbnailUrl = ch.LargeImageUrl, Color = Discord.Color.Red, Footer = new EmbedFooterBuilder() { IconUrl = ch.LargeImageUrl, Text = nom, } }.Build(); await ReplyAsync(Context.User.Mention, embed : embed); }
public async Task UserAsyncid([Remainder] long Id) { AnilistClient client = new AnilistClient(); var test = await client.GetStaffAsync(Id); string nom = test.FirstName + " " + test.LastName; string Description = string.Empty; if (test.Description.Length > 2048) { Description = test.Description.Replace("~!", "||").Replace("!~", "||").Remove(2048); } else { Description = test.Description.Replace("~!", "||").Replace("!~", "||"); } var embed = new EmbedBuilder() { Title = nom.PadLeft(4, ','), Url = test.SiteUrl, Description = Description, ThumbnailUrl = test.LargeImageUrl, Color = Discord.Color.Red, Footer = new EmbedFooterBuilder() { IconUrl = test.LargeImageUrl, Text = nom, } }.Build(); await ReplyAsync(Context.User.Mention, embed : embed); }
public async Task UserAsync([Remainder] long id) { AnilistClient client = new AnilistClient(); var ch = await client.GetStaffAsync(id); await ReplyAsync(embed : AnilistHelper.BuildEmbed(ch)); }
public async Task CharacterAsync([Remainder] string name) { AnilistClient client = new AnilistClient(); var ch = await client.GetCharacterAsync(name); await ReplyAsync(embed : AnilistHelper.BuildEmbed(ch)); }
public async Task GetAnime() { AnilistClient client = new AnilistClient(); var ch = await client.GetMediaAsync("miki", MediaFormat.TV); Assert.NotNull(ch); }
public async Task MangeAsync([Remainder] string query) { AnilistClient client = new AnilistClient(); var ch = await client.GetMediaAsync(query, MediaFormat.MANGA); await ReplyAsync(embed : AnilistHelper.BuildEmbed(ch)); }
protected async Task <IAsyncEnumerable <TItem> > GetItemsInfoAsync(string search) { var client = new AnilistClient(); return((await GetSearchItemsAsync(client, search)) .OrderBy(i => Distance(i, search)) .Select(async i => await GetItemAsyncCached(client, i))); }
public async Task FindCharacters() { AnilistClient client = new AnilistClient(); var ch = await client.SearchCharactersAsync("miki"); Assert.NotNull(ch); Assert.NotEmpty(ch.Items); }
public async Task SearchAlMangaAsync([Summary("Title to search")][Remainder] string name = "Azur Lane") { Logger.LogInfo($"Searching for {name} on anilist"); MangaResult mangaResult = await AnilistClient.GetMangaAsync(name); await ReplyAsync(embed : GetMangaResultEmbed(mangaResult, 0, new EmbedFooterBuilder())); }
public async Task FindMangas() { AnilistClient client = new AnilistClient(); var ch = await client.SearchMediaAsync("miki", type : MediaType.MANGA); Assert.All(ch.Items, i => Assert.Equal(MediaType.MANGA, i.Type)); Assert.NotNull(ch); Assert.NotEmpty(ch.Items); }
static async Task Main(string[] args) { client = new AnilistClient(); new LogBuilder() .AddLogEvent((msg, level) => Console.WriteLine(msg)) .Apply(); while (true) { Dictionary <string, string> @params = new Dictionary <string, string>(); Console.Write(">"); var query = Console.ReadLine().Split(' ').ToList(); Console.WriteLine(""); for (int i = 0; i < query.Count; i++) { if (query[i].StartsWith('-')) { var newParam = query[i].Split(':'); if (newParam.Length == 1) { @params.Add(newParam[0], "true"); } else if (newParam.Length > 1) { @params.Add(newParam[0], string.Join(':', newParam.Skip(1))); } query.RemoveAt(i); i--; } } if (query.Count == 0) { continue; } switch (query[0].ToLower()) { case "help": { } break; case "character": { await CharacterAction(query.Skip(1).Take(query.Count - 1), @params); } break; case "media": { await AnimeAction(query.Skip(1).Take(query.Count - 1), @params); } break; } } }
public async Task FindAnimesAndMangas() { AnilistClient client = new AnilistClient(); var ch = await client.SearchMediaAsync("miki"); Assert.True(ch.Items.Select(i => i.Type).Distinct().Count() == 2); Assert.NotNull(ch); Assert.NotEmpty(ch.Items); }
protected IAsyncEnumerable <TItem> GetItemsInfoAsync(string search) { var client = new AnilistClient(); return(GetSearchItemsAsync(client, search) .SelectAwait(async i => await GetItemAsyncCached(client, i)) .Where(a => a != null) .Select(a => a !)); }
public async Task GetStaff() { AnilistClient client = new AnilistClient(); var ch = await client.GetStaffAsync("Shinichi Fukuda"); Assert.NotNull(ch); ch = await client.GetStaffAsync(105350); Assert.NotNull(ch); }
protected override async Task <TItem> GetItemAsync(AnilistClient client, IMediaSearchResult item) { var mediaItem = await client.GetMediaAsync(item.Id); if (mediaItem == null) { return(null); } return(WrapItem(mediaItem)); }
public async Task GetCharacter() { AnilistClient client = new AnilistClient(); var ch = await client.GetCharacterAsync("rem"); Assert.NotNull(ch); ch = await client.GetCharacterAsync(37832); Assert.NotNull(ch); }
protected override async Task <ICharacter> GetItemAsync(AnilistClient client, ICharacterSearchResult searchItem) { var item = await client.GetCharacterAsync(searchItem.Id); if (item == null) { return(null); } return(new MikibotCharacter(item)); }
public async Task GetManga() { AnilistClient client = new AnilistClient(); var ch = await client.GetMediaAsync("miki", MediaFormat.MANGA); Assert.NotNull(ch); ch = await client.GetMediaAsync(104747); Assert.NotNull(ch); Assert.Equal(104747, ch.Id); }
protected async Task <TItem?> GetItemInfoAsync(string search) { search = search.ToLowerInvariant(); var client = new AnilistClient(); var result = await GetSearchItemsAsync(client, search).OrderBy(i => Distance(i, search)).Cast <TSearchItem?>().FirstOrDefaultAsync(); if (result == null) { return(null); } return(await GetItemAsyncCached(client, result)); }
[ItemCanBeNull] protected async Task <TItem> GetItemInfoAsync(string search) { search = search.ToLowerInvariant(); var client = new AnilistClient(); var result = await(await GetSearchItemsAsync(client, search)).FirstOrDefault(); if (result == null) { return(null); } return(await GetItemAsyncCached(client, result)); }
private async IAsyncEnumerable <TSearchItem> GetSearchItemsAsync(AnilistClient client, string search) { search = search.ToLowerInvariant(); for (var i = 0; true; i++) { var page = await SearchPage(client, search, i); foreach (var item in page.Items) { yield return(item); } if (!page.PageInfo.HasNextPage) { break; } } }
protected override async Task <TItem?> GetItemAsync(AnilistClient client, IMediaSearchResult item) { var mediaItem = await client.GetMediaAsync(item.Id); if (mediaItem == null) { return(null); } var sb = new StringBuilder(mediaItem.Description); sb.Replace("<b>", "**"); sb.Replace("</b>", "**"); sb.Replace("<i>", "_"); sb.Replace("</i>", "_"); sb.Replace("\n\n", "\n"); return(WrapItem(new MediaDescriptionReplacement(mediaItem, sb.ToString()))); }
private async Task <TItem?> GetItemAsyncCached(AnilistClient client, TSearchItem searchItem) { var cached = await _itemById.GetItem(ExtractId(searchItem)); if (cached != null) { return(cached); } var item = await GetItemAsync(client, searchItem); if (item == null) { return(null); } _cache.Add(item); return(item); }
private async Task <IAsyncEnumerable <TSearchItem> > GetSearchItemsAsync(AnilistClient client, string search) { search = search.ToLowerInvariant(); async Task <ISearchResult <TSearchItem> > Page(ISearchResult <TSearchItem> previous) { //Stop once there is no next page if (!(previous?.PageInfo.HasNextPage ?? true)) { return(null); } //Get next page var index = (previous?.PageInfo.CurrentPage ?? -1) + 1; var r = await SearchPage(client, search, index); return(r); } return(new SearchResultAsyncEnumerable <TSearchItem>(Page, 2)); }
public async Task UserAsyncm([Remainder] string query) { AnilistClient client = new AnilistClient(); var ch = await client.GetMediaAsync(query, MediaFormat.TV, MediaFormat.OVA, MediaFormat.MOVIE, MediaFormat.MUSIC, MediaFormat.ONA, MediaFormat.SPECIAL, MediaFormat.TV_SHORT); int count = 0; string Genres = "Genres: "; string Score = ch.Score.ToString(); while (count < ch.Genres.Count()) { Genres = Genres + ch.Genres[count] + ", "; count++; } Genres = Genres.Remove(Genres.Length - 2); string Longueur = String.Empty; if (ch.Status.StartsWith("FINISHED")) { Longueur = ch.Chapters + " chapitres, " + ch.Volumes + " volumes" + "\n" + "\n"; } var embed = new EmbedBuilder() { Title = ch.DefaultTitle, Url = ch.Url, Description = Genres + "\n" + "\n" + Longueur + ch.Description, ThumbnailUrl = ch.CoverImage, Color = Discord.Color.Red, Footer = new EmbedFooterBuilder() { IconUrl = ch.Url, Text = "AL Score: " + Score + "/100", } }.Build(); await ReplyAsync(Context.User.Mention, embed : embed); }
public async Task SearchAlUserAsync([Summary("Title to search")][Remainder] string target_name = null) { string username = await TryGetUserData(target_name, user => NotNullOrEmptyStringDatabaseAccessor(user, entry => entry.AnilistName)); if (username == null) { await ReplyAsync("> No user **{username}** found"); return; } Logger.LogInfo($"Searching for {username} on anilist"); UserResult?userResult = await AnilistClient.GetUserAsync(username); if (userResult == null) { await ReplyAsync($"> No user **{username}** found"); } else { await ReplyAsync(embed : GetUserResultEmbed(userResult.Value, 0, new EmbedFooterBuilder())); } }
protected abstract Task <ISearchResult <TSearchItem> > SearchPage(AnilistClient client, string search, int index);
protected override Task <ISearchResult <IMediaSearchResult> > SearchPage(AnilistClient client, string search, int index) { return(client.SearchMediaAsync(search, index, false, filter: _formats)); }
public async Task AnilistAsync([Remainder][Summary("Search query (use keyword `search:` to get multiple results)")] string query) { if (query == null) { throw new ArgumentNullException(nameof(query), "No input passed"); } AnilistClient anilist = new AnilistClient(); if (query.ToLower().StartsWith("search:")) { query = query.Replace("search:", ""); var results = await anilist.SearchMediaAsync(query).ConfigureAwait(false); EmbedBuilder _eb = new EmbedBuilder { Author = new EmbedAuthorBuilder { Name = $"SEARCH", IconUrl = "https://submission-manual.anilist.co/logo.png", }, Title = $"{results.Items.Count} results for {query}", Color = Discord.Color.Blue, Footer = new EmbedFooterBuilder { Text = "Anilist for Ranka" } }; foreach (var item in results.Items) { _eb.AddField(item.DefaultTitle, $"{item.Type} | [Link](https://anilist.co/{item.Type.ToString().ToLower()}/{item.Id})"); } await RankaReplyAsync(_eb).ConfigureAwait(false); return; } var res = await anilist.GetMediaAsync(query).ConfigureAwait(false); var color = await StringUtils.DiscordParseColor(new Uri(res.CoverImage)).ConfigureAwait(false); EmbedBuilder eb = new EmbedBuilder { Author = new EmbedAuthorBuilder { Name = $"{res.Type}", IconUrl = "https://submission-manual.anilist.co/logo.png", }, Title = res.DefaultTitle, Description = res.Description, Color = color, Url = res.Url, ThumbnailUrl = res.CoverImage, Footer = new EmbedFooterBuilder { Text = "Anilist for Ranka" } }; var score = res.Score.HasValue ? $"{res.Score.Value}/100" : "N/A"; eb.AddField("Japanese Title", res.NativeTitle, true); eb.AddField("Transcripted Title", res.RomajiTitle, true); eb.AddField("Score", score, true); eb.AddField("Genres", string.Join(", ", res.Genres)); if (res.Episodes.HasValue) { eb.AddField("Episodes", res.Episodes.Value, true); } if (res.Chapters.HasValue) { eb.AddField("Chapters", res.Chapters.Value, true); } if (res.Volumes.HasValue) { eb.AddField("Volumes", res.Volumes.Value, true); } eb.AddField("Status", res.Status, true); await RankaReplyAsync(eb).ConfigureAwait(false); }