using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Json; using System.Threading; using System.Threading.Tasks; namespace NadekoBot.Modules.Nsfw.Common { public class SafebooruImageDownloader : ImageDownloader { public SafebooruImageDownloader(HttpClient http) : base(Booru.Safebooru, http) { } public override async Task> DownloadImagesAsync(string[] tags, int page, bool isExplicit = false, CancellationToken cancel = default) { var tagString = ImageDownloaderHelper.GetTagString(tags, isExplicit: false); var uri = $"https://safebooru.org/index.php?page=dapi&s=post&q=index&limit=200&tags={tagString}&json=1&pid={page}"; var images = await _http.GetFromJsonAsync>(uri, _serializerOptions, cancellationToken: cancel); if (images is null) return new(); return images; } } }