mirror of
https://github.com/ultrasn0w/app.git
synced 2025-12-16 02:59:53 +01:00
Images
This commit is contained in:
@@ -17,7 +17,7 @@ internal static class BackendComms
|
||||
{
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "season");
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<Anime>>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ internal static class BackendComms
|
||||
var resp = await Client.SendAsync(msg);
|
||||
if (!resp.IsSuccessStatusCode)
|
||||
{
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
}
|
||||
|
||||
return resp.IsSuccessStatusCode;
|
||||
@@ -43,7 +43,7 @@ internal static class BackendComms
|
||||
{
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "anime/" + animeId);
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<Anime>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ internal static class BackendComms
|
||||
{
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "animesearch?q=" + query);
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<Anime>>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ internal static class BackendComms
|
||||
{
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "user");
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<User>>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ internal static class BackendComms
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "user/" + username);
|
||||
if (!resp.IsSuccessStatusCode)
|
||||
{
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ internal static class BackendComms
|
||||
{
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "watch");
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<Watch>>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ internal static class BackendComms
|
||||
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "watch/" + username);
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<Watch>>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ internal static class BackendComms
|
||||
{
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "watchext");
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<WatchExtended>>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ internal static class BackendComms
|
||||
|
||||
var resp = await Client.GetAsync(ApiBaseUrl + "watchext/" + username);
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<List<WatchExtended>>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ internal static class BackendComms
|
||||
using var content = new StringContent(JsonSerializer.Serialize(register), Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||
using var resp = await Client.PostAsync(ApiBaseUrl + "register", content);
|
||||
if (resp.IsSuccessStatusCode) return await resp.Content.ReadFromJsonAsync<Register>(JsonSerializerOptions);
|
||||
LogBoy.AddToLog(resp.RequestMessage?.RequestUri + " " + resp.StatusCode);
|
||||
await LogBoy.LogResponse(resp);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,11 @@ internal static class LogBoy
|
||||
{
|
||||
private static readonly StringBuilder Log = new();
|
||||
|
||||
internal static async Task LogResponse(HttpResponseMessage message)
|
||||
{
|
||||
AddToLog(message.RequestMessage?.RequestUri + " " + message.StatusCode + " " + await message.Content.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
internal static void AddToLog(string text)
|
||||
{
|
||||
Log.Append('[' + DateTime.Now.ToShortTimeString() + "] ");
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace APP.Utility;
|
||||
|
||||
internal static class SaveBoy
|
||||
{
|
||||
private static readonly string AuthFile = ".." + Path.DirectorySeparatorChar + "reg.json";
|
||||
private const string AuthFile = "reg.json";
|
||||
|
||||
internal static async Task<Auth?> ReadAuth()
|
||||
{
|
||||
|
||||
12
APP/Utility/WebBoy.cs
Normal file
12
APP/Utility/WebBoy.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace APP.Utility;
|
||||
|
||||
internal static class WebBoy
|
||||
{
|
||||
private static readonly HttpClient Client = new();
|
||||
|
||||
internal static async Task<Bitmap> DownloadImage(string url)
|
||||
{
|
||||
await using var s = await Client.GetStreamAsync(url);
|
||||
return new Bitmap(s);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user