Implemented /v2/Connector/<ConnectorName>/GetManga
This commit is contained in:
parent
b3fb53f6d8
commit
4cb7c941a2
@ -1,5 +1,6 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Tranga.MangaConnectors;
|
||||||
|
|
||||||
namespace Tranga.Server;
|
namespace Tranga.Server;
|
||||||
|
|
||||||
@ -12,8 +13,19 @@ public partial class Server
|
|||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> GetV2ConnectorConnectorNameGetManga(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> GetV2ConnectorConnectorNameGetManga(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
if(groups.Count < 1 || !_parent.GetConnectors().Contains(groups[1].Value))
|
if(groups.Count < 1 ||
|
||||||
|
!_parent.GetConnectors().Contains(groups[1].Value) ||
|
||||||
|
!_parent.TryGetConnector(groups[1].Value, out MangaConnector? connector) ||
|
||||||
|
connector is null)
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.BadRequest, $"Connector '{groups[1].Value}' does not exist.");
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.BadRequest, $"Connector '{groups[1].Value}' does not exist.");
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not Implemented");
|
|
||||||
|
if (requestParameters.TryGetValue("title", out string? title))
|
||||||
|
{
|
||||||
|
return (HttpStatusCode.OK, connector.GetManga(title));
|
||||||
|
}else if (requestParameters.TryGetValue("url", out string? url))
|
||||||
|
{
|
||||||
|
return (HttpStatusCode.OK, connector.GetMangaFromUrl(url));
|
||||||
|
}else
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.BadRequest, "Parameter 'title' or 'url' has to be set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user