From 8887cea718ef308d7fe0a8e7cb78f5537b77683b Mon Sep 17 00:00:00 2001 From: Glax Date: Fri, 26 Apr 2024 00:00:57 +0200 Subject: [PATCH] Add Endpoint POST /v2/Manga/internalId/ignoreChaptersBelow #167 --- Tranga/Server/Server.cs | 1 + Tranga/Server/v2Manga.cs | 16 ++++++++++++++++ docs/API_Calls_v2.md | 24 ++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/Tranga/Server/Server.cs b/Tranga/Server/Server.cs index 4916b37..cde7bd9 100644 --- a/Tranga/Server/Server.cs +++ b/Tranga/Server/Server.cs @@ -29,6 +29,7 @@ public partial class Server : GlobalBase, IDisposable 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 ("POST", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/ignoreChaptersBelow", PostV2MangaInternalIdIgnoreChaptersBelow), new ("GET", @"/v2/Jobs", GetV2Jobs), new ("GET", @"/v2/Jobs/Running", GetV2JobsRunning), new ("GET", @"/v2/Jobs/Waiting", GetV2JobsWaiting), diff --git a/Tranga/Server/v2Manga.cs b/Tranga/Server/v2Manga.cs index d661ae8..cee3dfa 100644 --- a/Tranga/Server/v2Manga.cs +++ b/Tranga/Server/v2Manga.cs @@ -76,4 +76,20 @@ public partial class Server }; return new ValueTuple(HttpStatusCode.OK, latest); } + + private ValueTuple PostV2MangaInternalIdIgnoreChaptersBelow(GroupCollection groups, Dictionary requestParameters) + { + if(groups.Count < 1 || + !_parent.TryGetPublicationById(groups[1].Value, out Manga? manga) || + manga is null) + return new ValueTuple(HttpStatusCode.NotFound, $"Manga with ID '{groups[1].Value} could not be found.'"); + if (requestParameters.TryGetValue("startChapter", out string? startChapterStr) && + float.TryParse(startChapterStr, out float startChapter)) + { + Manga manga1 = manga.Value; + manga1.ignoreChaptersBelow = startChapter; + return new ValueTuple(HttpStatusCode.OK, null); + }else + return new ValueTuple(HttpStatusCode.InternalServerError, "Parameter 'startChapter' missing, or failed to parse."); + } } \ No newline at end of file diff --git a/docs/API_Calls_v2.md b/docs/API_Calls_v2.md index df9c9a7..867b3fa 100644 --- a/docs/API_Calls_v2.md +++ b/docs/API_Calls_v2.md @@ -195,6 +195,30 @@ Returns the latest Chapter of the specified Manga. | 404 | Manga with `internalId` could not be found | +### ![POST](https://img.shields.io/badge/POST-00f) `/v2/Manga//ignoreChaptersBelow` + +
+ Request + + `internalId` is returned in the response of + * [GET /v2/Manga](#-v2manga) + * [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga) + * [GET /v2/Job/*jobId*](#-v2jobjobid) + + | Parameter | Value | + |--------------|----------------------------| + | startChapter | Chapter-number to start at | +
+ +
+ Returns + + | StatusCode | Meaning | + |------------|--------------------------------------------| + | 404 | Manga with `internalId` could not be found | + | 500 | Parsing Error | +
+ ## Jobs [^top](#top) ### ![GET](https://img.shields.io/badge/GET-0f0) `/v2/Jobs`