Closed GizmoCaritate closed 3 months ago
I changed the name of the PR to be more apt, since it's not just about E6AI anymore. Also the small console app i wrote to test has changed to this:
using System.Diagnostics;
using Noppes.E621;
using Noppes.E621.DbExport;
var newClient = new E621ClientBuilder()
.WithUserAgent("E621Client.Tests", "n/a", "NoppesTheFolf", "GitHub")
.WithBaseUrl(new Uri("https://e6ai.net"))
.Build();
var oldClient = new E621ClientBuilder()
.WithUserAgent("E621Client.Tests", "n/a", "NoppesTheFolf", "GitHub")
.WithBaseUrl(Imageboard.E926)
.Build();
try
{
if (!await newClient.LogInAsync("NoppesTheFolf", "someapitokenfrome6ai.net"))
throw new Exception("Could not login!");
if (!await oldClient.LogInAsync("NoppesTheFolf", "someapitokenfrome926.net"))
throw new Exception("Could not login!");
await TestPost(newClient);
await TestPost(oldClient);
await TestDbExport(newClient);
await TestDbExport(oldClient);
}
finally
{
newClient.Logout();
oldClient.Logout();
}
async Task TestPost(IE621Client client)
{
var post = await client.GetPostAsync(52584);
if (post is null)
throw new Exception("Could not get post data!");
Console.WriteLine($"new: {post.File?.Location}");
}
async Task TestDbExport(IE621Client client)
{
if (client.BaseUrl.Equals(E621Constants.DefaultBaseUrl.AbsoluteUri))
{
var dbExport = client.GetDbExportClient();
var exports = await dbExport.GetDbExportsAsync();
Console.WriteLine(exports.Latest(DbExportType.Post).FileName);
}
else
{
try
{
_ = client.GetDbExportClient();
}
catch (ArgumentException e)
{
Console.WriteLine(e.Message);
return;
}
Debug.Fail("Should get an exception when trying to use DB export an any image board other than E621.");
}
}
I have also updated the README to make users aware this functionality exists and how to use it. Please let me know if there are any changes you would like to see. Also I can update the version if you'd like but you might want to do that kind of thing yourself.
Failed conditions
B Maintainability Rating on New Code (required ≥ A)
See analysis details on SonarCloud
Catch issues before they fail your Quality Gate with our IDE extension SonarLint
PR for issue #17
I have added support for the E6AI.net imageboard. You can validate that this works by running the following code
Please let me know if this alright to merge. It's quite a small change but I require it to add e6ai support to my bot. Thank you!
P.S. Also let me know if I need to bump the version or if you will do that. I'm not as familiar with contributing to OS software.