Add Endpoint /v2/Manga/internalId/Chapters/Latest
This commit is contained in:
parent
3d08b1f9f2
commit
28a0efe488
@ -28,6 +28,7 @@ public partial class Server : GlobalBase, IDisposable
|
||||
new ("DELETE", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", DeleteV2MangaInternalId),
|
||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/Cover", GetV2MangaInternalIdCover),
|
||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/Chapters", GetV2MangaInternalIdChapters),
|
||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/Chapters/Latest", GetV2MangaInternalIdChaptersLatest),
|
||||
new ("GET", @"/v2/Jobs", GetV2Jobs),
|
||||
new ("GET", @"/v2/Jobs/Running", GetV2JobsRunning),
|
||||
new ("GET", @"/v2/Jobs/Waiting", GetV2JobsWaiting),
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user