Exemplo n.º 1
0
        public async Task LookUpHen()
        {
            var messageCache = Context.Channel.CachedMessages.Reverse();

            foreach (var messageCheck in messageCache)
            {
                if (!int.TryParse(messageCheck.ToString(), out var bookId))
                {
                    continue;
                }
                try
                {
                    StringBuilder sb   = new StringBuilder();
                    var           book = await _nHentai.GetBookAsync(bookId);

                    var imageUrl = _nHentai.GetBookThumbUrl(book);
                    var url      = "https://nhentai.net/g/" + $"{book.Id}/";
                    foreach (var tag in book.Tags)
                    {
                        sb.Append($"{tag.Name}, ");
                    }

                    await Context.Channel.SendSuccessNhentaiAsync(
                        $"{book.Title.Japanese}",
                        $"{book.Title.English}",
                        $"{sb}",
                        Convert.ToDateTime($"{book.UploadDate}"),
                        $"{book.NumPages}",
                        $"{url}", imageUrl);

                    return;
                }
                catch
                {
                    //
                }
            }
        }
Exemplo n.º 2
0
        public async Task TestBookThumbPictureResult()
        {
            // Get book no 123
            var book = await NHentaiClient.GetBookAsync(123);

            // Check this book is right media number
            Assert.AreEqual(635, book.MediaId);

            // Check url
            var imageUrl = NHentaiClient.GetBookThumbUrl(book);

            Assert.AreEqual(imageUrl, "https://t.nhentai.net/galleries/635/thumb.jpg");

            // Make sure image is downloaded
            var result = await NHentaiClient.GetBookThumbPictureAsync(book);

            Assert.AreEqual(true, result.Length > 0);
        }