diff --git a/Tranga/Server/v2Connector.cs b/Tranga/Server/v2Connector.cs index ac3b38a..29d4577 100644 --- a/Tranga/Server/v2Connector.cs +++ b/Tranga/Server/v2Connector.cs @@ -1,5 +1,6 @@ using System.Net; using System.Text.RegularExpressions; +using Tranga.MangaConnectors; namespace Tranga.Server; @@ -12,8 +13,19 @@ public partial class Server private ValueTuple GetV2ConnectorConnectorNameGetManga(GroupCollection groups, Dictionary 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.BadRequest, $"Connector '{groups[1].Value}' does not exist."); - return new ValueTuple(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.BadRequest, "Parameter 'title' or 'url' has to be set."); } } \ No newline at end of file