parent
7ed3846c5f
commit
4021237888
@ -24,7 +24,9 @@ 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/Mangas", GetV2Mangas),
|
new ("GET", @"/v2/Mangas", GetV2Mangas),
|
||||||
|
new ("GET", @"/v2/Manga/Search", GetV2MangaSearch),
|
||||||
new ("GET", @"/v2/Manga", GetV2Manga),
|
new ("GET", @"/v2/Manga", GetV2Manga),
|
||||||
|
new ("GET", @"/v2/Manga/sear", GetV2Manga),
|
||||||
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", GetV2MangaInternalId),
|
new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", GetV2MangaInternalId),
|
||||||
new ("DELETE", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", DeleteV2MangaInternalId),
|
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})/Cover", GetV2MangaInternalIdCover),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Tranga.Jobs;
|
using Tranga.Jobs;
|
||||||
|
using Tranga.MangaConnectors;
|
||||||
|
|
||||||
namespace Tranga.Server;
|
namespace Tranga.Server;
|
||||||
|
|
||||||
@ -27,6 +28,27 @@ public partial class Server
|
|||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ret);
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ValueTuple<HttpStatusCode, object?> GetV2MangaSearch(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
|
{
|
||||||
|
if(!requestParameters.TryGetValue("title", out string? title))
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.BadRequest, "Missing parameter 'title'.");
|
||||||
|
List<Manga> ret = new();
|
||||||
|
List<Thread> threads = new();
|
||||||
|
foreach (MangaConnector mangaConnector in _connectors)
|
||||||
|
{
|
||||||
|
Thread t = new (() =>
|
||||||
|
{
|
||||||
|
ret.AddRange(mangaConnector.GetManga(title));
|
||||||
|
});
|
||||||
|
t.Start();
|
||||||
|
threads.Add(t);
|
||||||
|
}
|
||||||
|
while(threads.Any(t => t.ThreadState is ThreadState.Running or ThreadState.WaitSleepJoin))
|
||||||
|
Thread.Sleep(10);
|
||||||
|
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ret);
|
||||||
|
}
|
||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
if(groups.Count < 1 ||
|
if(groups.Count < 1 ||
|
||||||
|
@ -77,6 +77,29 @@ Returns all known Manga.
|
|||||||
List of internalIds.
|
List of internalIds.
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Manga/Search`
|
||||||
|
|
||||||
|
Initiates a search for a Manga on all Connectors.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Request</summary>
|
||||||
|
|
||||||
|
|
||||||
|
| Parameter | Value |
|
||||||
|
|-----------|-------------------------------------------------|
|
||||||
|
| title | Search Term |
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Returns</summary>
|
||||||
|
|
||||||
|
List of [Manga](Types.md#Manga)
|
||||||
|
|
||||||
|
| StatusCode | Meaning |
|
||||||
|
|------------|-------------------|
|
||||||
|
| 400 | Parameter missing |
|
||||||
|
</details>
|
||||||
|
|
||||||
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Manga/<internalId>`
|
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Manga/<internalId>`
|
||||||
|
|
||||||
Returns the specified Manga.
|
Returns the specified Manga.
|
||||||
|
Loading…
Reference in New Issue
Block a user