Added UI app.

This commit is contained in:
2025-06-01 22:29:14 -04:00
parent 1348684144
commit 7dbcdc6169
36 changed files with 1645 additions and 25 deletions

View File

@@ -20,17 +20,28 @@ namespace MangaReader.Core.Sources.MangaDex.Api
}
private async Task<MangaDexResponse?> GetAsync(string url, CancellationToken cancellationToken)
{
//string response = await httpService.GetStringAsync(url, cancellationToken);
//return JsonSerializer.Deserialize<MangaDexResponse>(response, _jsonSerializerOptions);
return await GetAsync<MangaDexResponse>(url, cancellationToken);
}
private async Task<T?> GetAsync<T>(string url, CancellationToken cancellationToken)
{
string response = await httpService.GetStringAsync(url, cancellationToken);
return JsonSerializer.Deserialize<MangaDexResponse>(response, _jsonSerializerOptions);
return JsonSerializer.Deserialize<T?>(response, _jsonSerializerOptions);
}
public async Task<MangaDexResponse?> SearchMangaByTitleAsync(string title, CancellationToken cancellationToken)
{
string normalizedKeyword = GetNormalizedKeyword(title);
return await GetAsync($"https://api.mangadex.org/manga?title={normalizedKeyword}&limit=5", cancellationToken);
//return await GetAsync($"https://api.mangadex.org/manga?title={normalizedKeyword}&limit=5", cancellationToken);
return await GetAsync($"https://api.mangadex.org/manga?title={normalizedKeyword}&limit=10&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&includes[]=cover_art&order[followedCount]=desc&order[relevance]=desc", cancellationToken);
//
}
public async Task<MangaDexResponse?> SearchMangaByAuthorAsync(string author, CancellationToken cancellationToken)
@@ -64,15 +75,24 @@ namespace MangaReader.Core.Sources.MangaDex.Api
public async Task<MangaDexChapterResponse?> GetChapterAsync(Guid chapterGuid, CancellationToken cancellationToken)
{
string url = $"https://api.mangadex.org/at-home/server/{chapterGuid}?forcePort443=false";
string response = await httpService.GetStringAsync(url, cancellationToken);
//string url = $"https://api.mangadex.org/at-home/server/{chapterGuid}?forcePort443=false";
//string response = await httpService.GetStringAsync(url, cancellationToken);
return JsonSerializer.Deserialize<MangaDexChapterResponse>(response, _jsonSerializerOptions);
//return JsonSerializer.Deserialize<MangaDexChapterResponse>(response, _jsonSerializerOptions);
return await GetAsync<MangaDexChapterResponse>($"https://api.mangadex.org/at-home/server/{chapterGuid}?forcePort443=false", cancellationToken);
}
public async Task<MangaDexResponse?> GetCoverArtAsync(Guid mangaGuid, CancellationToken cancellationToken)
{
return await GetAsync($"https://api.mangadex.org/cover?order[volume]=asc&manga[]={mangaGuid}&limit=100&offset=0", cancellationToken);
return await GetCoverArtAsync([mangaGuid], cancellationToken);
//return await GetAsync($"https://api.mangadex.org/cover?order[volume]=asc&manga[]={mangaGuid}&limit=100&offset=0", cancellationToken);
}
public async Task<MangaDexResponse?> GetCoverArtAsync(Guid[] mangaGuids, CancellationToken cancellationToken)
{
string mangaGuidQuery = string.Join("&manga[]=", mangaGuids);
return await GetAsync($"https://api.mangadex.org/cover?order[volume]=asc&manga[]={mangaGuidQuery}&limit=100&offset=0", cancellationToken);
}
}
}