Fixed rule34, small refactor of the downloader classes

This commit is contained in:
Kwoth
2022-05-12 10:23:01 +02:00
parent b02768a08e
commit 1db97decd1
15 changed files with 69 additions and 41 deletions

View File

@@ -5,7 +5,7 @@ namespace NadekoBot.Modules.Nsfw.Common;
public class E621ImageDownloader : ImageDownloader<E621Object>
{
public E621ImageDownloader(HttpClient http)
public E621ImageDownloader(IHttpClientFactory http)
: base(Booru.E621, http)
{
}
@@ -20,7 +20,8 @@ public class E621ImageDownloader : ImageDownloader<E621Object>
var uri = $"https://e621.net/posts.json?limit=32&tags={tagString}&page={page}";
using var req = new HttpRequestMessage(HttpMethod.Get, uri);
req.Headers.AddFakeHeaders();
using var res = await _http.SendAsync(req, cancel);
using var http = _http.CreateClient();
using var res = await http.SendAsync(req, cancel);
res.EnsureSuccessStatusCode();
var data = await res.Content.ReadFromJsonAsync<E621Response>(_serializerOptions, cancel);