mirror of
https://github.com/C9Glax/tranga.git
synced 2025-02-23 07:40:13 +01:00
GET LibraryTypes Create and Test set url to lowercase
Set Komga to also require username and password
This commit is contained in:
parent
9d47445339
commit
96b5921ed6
@ -39,24 +39,22 @@ public partial class Server
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"LibraryType {groups[1].Value} does not exist.");
|
||||
}
|
||||
|
||||
if(!requestParameters.TryGetValue("URL", out string? url))
|
||||
if(!requestParameters.TryGetValue("url", out string? url))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
||||
|
||||
switch (libraryType)
|
||||
{
|
||||
case LibraryConnector.LibraryType.Kavita:
|
||||
if(!requestParameters.TryGetValue("username", out string? username))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
||||
if(!requestParameters.TryGetValue("password", out string? password))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
|
||||
|
||||
switch (libraryType)
|
||||
{
|
||||
case LibraryConnector.LibraryType.Kavita:
|
||||
Kavita kavita = new (this, url, username, password);
|
||||
libraryConnectors.RemoveWhere(lc => lc.libraryType == LibraryConnector.LibraryType.Kavita);
|
||||
libraryConnectors.Add(kavita);
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, kavita);
|
||||
case LibraryConnector.LibraryType.Komga:
|
||||
if(!requestParameters.TryGetValue("auth", out string? auth))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
|
||||
Komga komga = new (this, url, auth);
|
||||
Komga komga = new (this, url, username, password);
|
||||
libraryConnectors.RemoveWhere(lc => lc.libraryType == LibraryConnector.LibraryType.Komga);
|
||||
libraryConnectors.Add(komga);
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, komga);
|
||||
@ -72,16 +70,16 @@ public partial class Server
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"LibraryType {groups[1].Value} does not exist.");
|
||||
}
|
||||
|
||||
if(!requestParameters.TryGetValue("URL", out string? url))
|
||||
if(!requestParameters.TryGetValue("url", out string? url))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'url' missing.");
|
||||
|
||||
switch (libraryType)
|
||||
{
|
||||
case LibraryConnector.LibraryType.Kavita:
|
||||
if(!requestParameters.TryGetValue("username", out string? username))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'username' missing.");
|
||||
if(!requestParameters.TryGetValue("password", out string? password))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'password' missing.");
|
||||
|
||||
switch (libraryType)
|
||||
{
|
||||
case LibraryConnector.LibraryType.Kavita:
|
||||
Kavita kavita = new (this, url, username, password);
|
||||
return kavita.Test() switch
|
||||
{
|
||||
@ -89,9 +87,7 @@ public partial class Server
|
||||
_ => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.FailedDependency, kavita)
|
||||
};
|
||||
case LibraryConnector.LibraryType.Komga:
|
||||
if(!requestParameters.TryGetValue("auth", out string? auth))
|
||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotAcceptable, "Parameter 'auth' missing.");
|
||||
Komga komga = new (this, url, auth);
|
||||
Komga komga = new (this, url, username, password);
|
||||
return komga.Test() switch
|
||||
{
|
||||
true => new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, komga),
|
||||
|
@ -804,22 +804,10 @@ Creates a Library-Connector of the specified Type.
|
||||
`Type` is returned by [GET /v2/LibraryConnector/Types](#-v2libraryconnectortypes)
|
||||
|
||||
| Parameter | Value |
|
||||
|-------------|--------------------|
|
||||
| URL | URL of the Library |
|
||||
|
||||
#### Type specific Parameters (must be included for each)
|
||||
* Komga
|
||||
|
||||
| Parameter | Value |
|
||||
|-----------|-------------------------------------------------------------------------------------------------------------------|
|
||||
| auth | [Base64 encoded Basic-Authentication-String](https://datatracker.ietf.org/doc/html/rfc7617) (`username:password`) |
|
||||
|
||||
* Kavita
|
||||
|
||||
| Parameter | Value |
|
||||
|-----------|-----------------|
|
||||
| username | Kavita Username |
|
||||
| password | Kavita Password |
|
||||
|-----------|--------------------|
|
||||
| url | URL of the Library |
|
||||
| username | Username |
|
||||
| password | Password |
|
||||
</details>
|
||||
|
||||
<details>
|
||||
@ -844,22 +832,10 @@ Tests a Library-Connector of the specified Type.
|
||||
`Type` is returned by [GET /v2/LibraryConnector/Types](#-v2libraryconnectortypes)
|
||||
|
||||
| Parameter | Value |
|
||||
|-------------|--------------------|
|
||||
| URL | URL of the Library |
|
||||
|
||||
#### Type specific Parameters (must be included for each)
|
||||
* Komga
|
||||
|
||||
| Parameter | Value |
|
||||
|-----------|-------------------------------------------------------------------------------------------------------------------|
|
||||
| auth | [Base64 encoded Basic-Authentication-String](https://datatracker.ietf.org/doc/html/rfc7617) (`username:password`) |
|
||||
|
||||
* Kavita
|
||||
|
||||
| Parameter | Value |
|
||||
|-----------|-----------------|
|
||||
| username | Kavita Username |
|
||||
| password | Kavita Password |
|
||||
|-----------|--------------------|
|
||||
| url | URL of the Library |
|
||||
| username | Username |
|
||||
| password | Password |
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
Loading…
x
Reference in New Issue
Block a user