Compare commits
No commits in common. "37266ea0952b024b30b328ebab9bb7f337a9db77" and "7c7f711bb482bc0c5e02f6c525122b7f200541c1" have entirely different histories.
37266ea095
...
7c7f711bb4
@ -37,19 +37,12 @@ public class Kavita : LibraryConnector
|
||||
RequestUri = new Uri($"{baseUrl}/api/Account/login"),
|
||||
Content = new StringContent($"{{\"username\":\"{username}\",\"password\":\"{password}\"}}", System.Text.Encoding.UTF8, "application/json")
|
||||
};
|
||||
try
|
||||
{
|
||||
HttpResponseMessage response = client.Send(requestMessage);
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(response.Content.ReadAsStream());
|
||||
if (result is not null)
|
||||
return result["token"]!.GetValue<string>();
|
||||
}
|
||||
catch (HttpRequestException e)
|
||||
{
|
||||
Console.WriteLine($"Unable to retrieve token:\n\r{e}");
|
||||
}
|
||||
Console.WriteLine("Kavita: Did not receive token.");
|
||||
throw new Exception("Kavita: Did not receive token.");
|
||||
|
||||
HttpResponseMessage response = client.Send(requestMessage);
|
||||
JsonObject? result = JsonSerializer.Deserialize<JsonObject>(response.Content.ReadAsStream());
|
||||
if (result is not null)
|
||||
return result["token"]!.GetValue<string>();
|
||||
else throw new Exception("Did not receive token.");
|
||||
}
|
||||
|
||||
public override void UpdateLibrary()
|
||||
|
@ -401,7 +401,8 @@ public class Server : GlobalBase
|
||||
break;
|
||||
case "LibraryConnectors/Update":
|
||||
if (!requestVariables.TryGetValue("libraryConnector", out string? libraryConnectorStr) ||
|
||||
!Enum.TryParse(libraryConnectorStr, out LibraryConnector.LibraryType libraryConnectorType))
|
||||
!Enum.TryParse(libraryConnectorStr,
|
||||
out LibraryConnector.LibraryType libraryConnectorType))
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
@ -418,7 +419,10 @@ public class Server : GlobalBase
|
||||
}
|
||||
AddLibraryConnector(new Kavita(this, kavitaUrl, kavitaUsername, kavitaPassword));
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
}else if (libraryConnectorType is LibraryConnector.LibraryType.Komga)
|
||||
break;
|
||||
}
|
||||
|
||||
if (libraryConnectorType is LibraryConnector.LibraryType.Komga)
|
||||
{
|
||||
if (!requestVariables.TryGetValue("komgaUrl", out string? komgaUrl) ||
|
||||
!requestVariables.TryGetValue("komgaAuth", out string? komgaAuth))
|
||||
@ -428,10 +432,7 @@ public class Server : GlobalBase
|
||||
}
|
||||
AddLibraryConnector(new Komga(this, komgaUrl, komgaAuth));
|
||||
SendResponse(HttpStatusCode.Accepted, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "LogMessages":
|
||||
|
Loading…
Reference in New Issue
Block a user