mirror of
https://github.com/C9Glax/tranga.git
synced 2025-04-16 05:13:18 +02:00
Added Endpoint /v2/Manga lists all known Manga
Implemented /v2/Manga/*
This commit is contained in:
parent
c3231327f9
commit
ea866e0136
@ -23,10 +23,11 @@ public partial class Server : GlobalBase, IDisposable
|
|||||||
{
|
{
|
||||||
new ("GET", @"/v2/Connector/Types", GetV2ConnectorTypes),
|
new ("GET", @"/v2/Connector/Types", GetV2ConnectorTypes),
|
||||||
new ("GET", @"/v2/Connector/([a-zA-Z]+)/GetManga", GetV2ConnectorConnectorNameGetManga),
|
new ("GET", @"/v2/Connector/([a-zA-Z]+)/GetManga", GetV2ConnectorConnectorNameGetManga),
|
||||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9+/]*={0,3})", GetV2MangaInternalId),
|
new ("GET", @"/v2/Manga", GetV2Manga),
|
||||||
new ("DELETE", @"/v2/Manga/([-A-Za-z0-9+/]*={0,3})", DeleteV2MangaInternalId),
|
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", GetV2MangaInternalId),
|
||||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9+/]*={0,3})/Cover", GetV2MangaInternalIdCover),
|
new ("DELETE", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", DeleteV2MangaInternalId),
|
||||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9+/]*={0,3})/Chapters", GetV2MangaInternalIdChapters),
|
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/Jobs", GetV2Jobs),
|
new ("GET", @"/v2/Jobs", GetV2Jobs),
|
||||||
new ("GET", @"/v2/Jobs/Running", GetV2JobsRunning),
|
new ("GET", @"/v2/Jobs/Running", GetV2JobsRunning),
|
||||||
new ("GET", @"/v2/Jobs/Waiting", GetV2JobsWaiting),
|
new ("GET", @"/v2/Jobs/Waiting", GetV2JobsWaiting),
|
||||||
|
@ -1,27 +1,63 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Tranga.Jobs;
|
||||||
|
|
||||||
namespace Tranga.Server;
|
namespace Tranga.Server;
|
||||||
|
|
||||||
public partial class Server
|
public partial class Server
|
||||||
{
|
{
|
||||||
|
private ValueTuple<HttpStatusCode, object?> GetV2Manga(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
|
{
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, cachedPublications.Select(m => m.internalId));
|
||||||
|
}
|
||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not Implemented");
|
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.'");
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, manga);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> DeleteV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> DeleteV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not Implemented");
|
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.'");
|
||||||
|
Job[] jobs = _parent.jobBoss.GetJobsLike(publication: manga).ToArray();
|
||||||
|
_parent.jobBoss.RemoveJobs(jobs);
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalIdCover(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalIdCover(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not Implemented");
|
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.'");
|
||||||
|
string filePath = settings.GetFullCoverPath((Manga)manga!);
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
FileStream coverStream = new(filePath, FileMode.Open);
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, coverStream);
|
||||||
|
}
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, "Cover-File not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalIdChapters(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalIdChapters(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not Implemented");
|
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.'");
|
||||||
|
|
||||||
|
Chapter[] chapters = requestParameters.TryGetValue("language", out string? parameter) switch
|
||||||
|
{
|
||||||
|
true => manga.Value.mangaConnector.GetChapters((Manga)manga, parameter),
|
||||||
|
false => manga.Value.mangaConnector.GetChapters((Manga)manga)
|
||||||
|
};
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, chapters);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -67,6 +67,16 @@ Returns the Manga from the specified Manga Connector.
|
|||||||
|
|
||||||
## Manga <sup>[^top](#top)</sup>
|
## Manga <sup>[^top](#top)</sup>
|
||||||
|
|
||||||
|
### <sub></sub> `/v2/Manga`
|
||||||
|
|
||||||
|
Returns all known Manga.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Returns</summary>
|
||||||
|
|
||||||
|
List of internalIds.
|
||||||
|
</details>
|
||||||
|
|
||||||
### <sub></sub> `/v2/Manga/<internalId>`
|
### <sub></sub> `/v2/Manga/<internalId>`
|
||||||
|
|
||||||
Returns the specified Manga.
|
Returns the specified Manga.
|
||||||
@ -75,6 +85,7 @@ Returns the specified Manga.
|
|||||||
<summary>Request</summary>
|
<summary>Request</summary>
|
||||||
|
|
||||||
`internalId` is returned in the response of
|
`internalId` is returned in the response of
|
||||||
|
* [GET /v2/Manga](#-v2manga)
|
||||||
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
||||||
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
||||||
</details>
|
</details>
|
||||||
@ -97,6 +108,7 @@ Deletes all associated Jobs for the specified Manga
|
|||||||
<summary>Request</summary>
|
<summary>Request</summary>
|
||||||
|
|
||||||
`internalId` is returned in the response of
|
`internalId` is returned in the response of
|
||||||
|
* [GET /v2/Manga](#-v2manga)
|
||||||
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
||||||
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
||||||
</details>
|
</details>
|
||||||
@ -118,6 +130,7 @@ Returns the URL for the Cover of the specified Manga.
|
|||||||
<summary>Request</summary>
|
<summary>Request</summary>
|
||||||
|
|
||||||
`internalId` is returned in the response of
|
`internalId` is returned in the response of
|
||||||
|
* [GET /v2/Manga](#-v2manga)
|
||||||
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
||||||
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
||||||
</details>
|
</details>
|
||||||
@ -140,8 +153,13 @@ Returns the Chapter-list for the specified Manga.
|
|||||||
<summary>Request</summary>
|
<summary>Request</summary>
|
||||||
|
|
||||||
`internalId` is returned in the response of
|
`internalId` is returned in the response of
|
||||||
|
* [GET /v2/Manga](#-v2manga)
|
||||||
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
||||||
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
||||||
|
|
||||||
|
| Parameter | Value |
|
||||||
|
|------------|------------------------|
|
||||||
|
| *language* | Language to search for |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@ -162,6 +180,7 @@ Returns the latest Chapter of the specified Manga.
|
|||||||
<summary>Request</summary>
|
<summary>Request</summary>
|
||||||
|
|
||||||
`internalId` is returned in the response of
|
`internalId` is returned in the response of
|
||||||
|
* [GET /v2/Manga](#-v2manga)
|
||||||
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
||||||
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
||||||
</details>
|
</details>
|
||||||
@ -245,6 +264,7 @@ Creates a Job.
|
|||||||
|
|
||||||
|
|
||||||
`internalId` is returned in the response of
|
`internalId` is returned in the response of
|
||||||
|
* [GET /v2/Manga](#-v2manga)
|
||||||
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
* [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga)
|
||||||
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
* [GET /v2/Job/*jobId*](#-v2jobjobid)
|
||||||
</details>
|
</details>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user