mirror of
https://github.com/C9Glax/tranga.git
synced 2025-07-07 11:21:35 +02:00
Add Endpoint /v2/Manga/internalId/Chapters/Latest
This commit is contained in:
@ -61,4 +61,19 @@ public partial class Server
|
||||
};
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, chapters);
|
||||
}
|
||||
|
||||
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalIdChaptersLatest(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||
{
|
||||
if(groups.Count < 1 ||
|
||||
!_parent.TryGetPublicationById(groups[1].Value, out Manga? manga) ||
|
||||
manga is null)
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"Manga with ID '{groups[1].Value} could not be found.'");
|
||||
|
||||
float latest = requestParameters.TryGetValue("language", out string? parameter) switch
|
||||
{
|
||||
true => float.Parse(manga.Value.mangaConnector.GetChapters(manga.Value, parameter).Max().chapterNumber),
|
||||
false => float.Parse(manga.Value.mangaConnector.GetChapters(manga.Value).Max().chapterNumber)
|
||||
};
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, latest);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user