Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added new tasks, removed deprecated tasks and aligned with latest documentation. #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CapSolver.Tests/BaseMethodTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace CapSolver.Tests;
public class BaseMethodTests
{
[Fact]
public async void TestBalance()
public async Task TestBalance()
{
var client = new CapSolverClient(Environment.GetEnvironmentVariable("APIKEY")!, false);
float balance = await client.GetBalance();
Expand All @@ -12,7 +12,7 @@ public async void TestBalance()
}

[Fact]
public async void TestPackages()
public async Task TestPackages()
{
var client = new CapSolverClient(Environment.GetEnvironmentVariable("APIKEY")!, false);
List<string?> packages = await client.GetPackages();
Expand Down
4 changes: 2 additions & 2 deletions CapSolver.Tests/HCaptchaTaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ namespace CapSolver.Tests;
public class HCaptchaTaskTest
{
[Fact]
public async void Test()
public async Task Test()
{
var client = new CapSolverClient(Environment.GetEnvironmentVariable("APIKEY")!, false);
var task = new HCaptchaTask("https://lessons.zennolab.com/captchas/hcaptcha/?level=easy",
"472fc7af-86a4-4382-9a49-ca9090474471");
string id = await client.CreateTask(task);
Assert.IsType<string>(id);
Assert.NotNull(id);
var response = await client.JoinTaskResult<HCaptchaTaskResponse>(id);
var response = await client.JoinTaskResult<HCaptchaResponse>(id);
Assert.NotNull(response.GReCaptchaResponse);
Assert.IsType<string>(response.GReCaptchaResponse);
}
Expand Down
2 changes: 1 addition & 1 deletion CapSolver.Tests/ReCaptchaV2TaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace CapSolver.Tests;
public class ReCaptchaV2TaskTest
{
[Fact]
public async void Test()
public async Task Test()
{
var client = new CapSolverClient(Environment.GetEnvironmentVariable("APIKEY")!, false);
var task = new ReCaptchaV2Task("https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
Expand Down
2 changes: 1 addition & 1 deletion CapSolver.Tests/ReCaptchaV3TaskTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace CapSolver.Tests;
public class ReCaptchaV3TaskTest
{
[Fact]
public async void Test()
public async Task Test()
{
var client = new CapSolverClient(Environment.GetEnvironmentVariable("APIKEY")!, false);
var task = new ReCaptchaV3Task("https://lessons.zennolab.com/captchas/recaptcha/v3.php?level=beta",
Expand Down
24 changes: 12 additions & 12 deletions CapSolver/CapSolver.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>CapSolver</PackageId>
<Version>1.2.1</Version>
<Authors>Alperen Sert</Authors>
<Company>Alperen Sert</Company>
<PackageTags>CapSolver,ReCaptcha v2 solver, Bypass captcha, anti-captcha,</PackageTags>
<PackageId>CapSolver</PackageId>
<Version>2.0.0</Version>
<Authors>Alperen Sert</Authors>
<Company>Alperen Sert</Company>
<PackageTags>CapSolver,ReCaptcha v2 solver, Bypass captcha, anti-captcha,</PackageTags>
<Description>CapSolver.com Library for .NET Core</Description>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/alperensert/CapSolver</PackageProjectUrl>
<RepositoryUrl>https://github.com/alperensert/CapSolver</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RespositoryType>git</RespositoryType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<None Include="../README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<None Include="../README.md" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
20 changes: 8 additions & 12 deletions CapSolver/CapSolverClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,11 @@ public async Task<string> CreateTask(ITask task)
break;
}
}
var method = task switch
{
AntiAkamaiBMPTask => Endpoints.CreateTaskAntiAkamai,
AntiKasadaTask => Endpoints.CreateTaskKasada,
_ => Endpoints.CreateTask
};
if (task is HCaptchaTurboTask && IsProxyActive() == false)
throw new CapSolverException(13, "PROXY_NEEDED", "HCaptchaTurboTask requires your own proxies.");
var r = await CheckResponse<CreateTaskResponse>(await MakeRequest(method, data));

if (task is DatadomeSliderTask && !IsProxyActive())
throw new CapSolverException(13, "PROXY_NEEDED", "DatadomeSliderTask requires your own proxies.");

var r = await CheckResponse<CreateTaskResponse>(await MakeRequest(Endpoints.CreateTask, data));
return r.TaskId;
}

Expand All @@ -120,7 +116,7 @@ public async Task<string> CreateTask(ITask task)

public void DisableProxy() => _proxy = null;

private bool IsReady<T>(TaskResponse<T> response) where T : ITaskResponse => response.Status == "ready";
private static bool IsReady<T>(TaskResponse<T> response) where T : ITaskResponse => response.Status == "ready";

private async Task<HttpResponseMessage> MakeRequest(string endpoint, string data)
{
Expand All @@ -139,7 +135,7 @@ private async Task<HttpResponseMessage> MakeRequest(string endpoint, string data
return response;
}

private void CheckResponse(ErrorResponse? response)
private static void CheckResponse(ErrorResponse? response)
{
if (response == null)
{
Expand All @@ -151,7 +147,7 @@ private void CheckResponse(ErrorResponse? response)
}
}

private async Task<T> CheckResponse<T>(HttpResponseMessage response) where T : ErrorResponse
private static async Task<T> CheckResponse<T>(HttpResponseMessage response) where T : ErrorResponse
{
try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace CapSolver.Utilities;
namespace CapSolver;

[System.Serializable]
public class CapSolverException : System.Exception
[Serializable]
public class CapSolverException : Exception
{
public int ErrorId { get; set; }

Expand Down
19 changes: 0 additions & 19 deletions CapSolver/Models/Responses/AntiAkamaiBMPResponse.cs

This file was deleted.

11 changes: 11 additions & 0 deletions CapSolver/Models/Responses/AntiAwsWafResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using CapSolver.Utilities;
using Newtonsoft.Json;

namespace CapSolver.Models.Responses;

public class AntiAwsWafResponse : ITaskResponse
{
[JsonRequired]
[JsonProperty("cookie")]
public string Cookie { get; set; } = null!;
}
19 changes: 0 additions & 19 deletions CapSolver/Models/Responses/AntiKasadaResponse.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace CapSolver.Models.Responses;

public class AntiCloudflareResponse : ITaskResponse
public class AntiTurnstileResponse : ITaskResponse
{
[JsonRequired]
[JsonProperty("token")]
Expand Down
4 changes: 4 additions & 0 deletions CapSolver/Models/Responses/AwsWafClassificationResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace CapSolver.Models.Responses;

public class AwsWafClassificationResponse : ITaskResponse
{
[JsonRequired]
[JsonProperty("objects")]
public IList<int> Objects { get; set; } = null!;

[JsonRequired]
[JsonProperty("box")]
public IList<float> Box { get; set; } = null!;
Expand Down
15 changes: 0 additions & 15 deletions CapSolver/Models/Responses/BinanceCaptchaResponse.cs

This file was deleted.

3 changes: 2 additions & 1 deletion CapSolver/Models/Responses/DatadomeSliderResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ namespace CapSolver.Models.Responses;

public class DatadomeSliderResponse : ITaskResponse
{
[JsonRequired]
[JsonProperty("cookie")]
public string Cookie { get; set; }
public string Cookie { get; set; } = null!;

[JsonRequired]
[JsonProperty("userAgent")]
Expand Down
19 changes: 0 additions & 19 deletions CapSolver/Models/Responses/FunCaptchaClassificationResponse.cs

This file was deleted.

11 changes: 0 additions & 11 deletions CapSolver/Models/Responses/FunCaptchaTaskResponse.cs

This file was deleted.

12 changes: 6 additions & 6 deletions CapSolver/Models/Responses/GeeTestV4Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ namespace CapSolver.Models.Responses;
public class GeeTestV4Response
{
[JsonProperty("captcha_id")]
public string CaptchaId { get; set; }
public string? CaptchaId { get; set; }

[JsonProperty("captcha_output")]
public string CaptchaOutput { get; set; }
public string? CaptchaOutput { get; set; }

[JsonProperty("gen_time")]
public string GenTime { get; set; }
public string? GenTime { get; set; }

[JsonProperty("lot_number")]
public string LotNumber { get; set; }
public string? LotNumber { get; set; }

[JsonProperty("pass_token")]
public string Token { get; set; }
public string? Token { get; set; }

[JsonProperty("risk_type")]
public string RiskType { get; set; }
public string? RiskType { get; set; }

}
5 changes: 4 additions & 1 deletion CapSolver/Models/Responses/HCaptchaClassificationResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class HCaptchaClassificationResponse : ITaskResponse
[JsonProperty("box")]
public IList<float>? Box { get; set; }

[JsonProperty("tags")]
public IList<bool>? Tags { get; set; }

[JsonProperty("imageSize")]
public Tuple<int, int> ImageSize { get; set; }
public Tuple<int, int>? ImageSize { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace CapSolver.Models.Responses;

public class HCaptchaTaskResponse : ReCaptchaV2Response, ITaskResponse
public class HCaptchaResponse : ReCaptchaV2Response, ITaskResponse
{
[JsonRequired]
[JsonProperty("timestamp")]
Expand Down
4 changes: 2 additions & 2 deletions CapSolver/Models/Responses/MtCaptchaResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace CapSolver.Models.Responses;
public class MtCaptchaResponse : ITaskResponse
{
[JsonProperty("token")]
public string Token { get; set; }
public string? Token { get; set; }

[JsonProperty("userAgent")]
public string UserAgent { get; set; }
public string? UserAgent { get; set; }
}
20 changes: 20 additions & 0 deletions CapSolver/Models/Responses/ReCaptchaV2ClassificationResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using CapSolver.Utilities;
using Newtonsoft.Json;

namespace CapSolver.Models.Responses;

public class ReCaptchaV2ClassificationResponse : ITaskResponse
{
[JsonRequired]
[JsonProperty("type")]
public string Type { get; set; } = null!;

[JsonProperty("size")]
public int Size { get; set; }

[JsonProperty("objects")]
public IList<int>? Objects { get; set; } = null!;

[JsonProperty("hasObject")]
public bool? HasObject { get; set; }
}
3 changes: 1 addition & 2 deletions CapSolver/Models/Responses/ReCaptchaV3Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
namespace CapSolver.Models.Responses;

public class ReCaptchaV3Response : ReCaptchaV2Response, ITaskResponse
{

{
}
16 changes: 16 additions & 0 deletions CapSolver/Models/Responses/VisionEngineClassificationResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using CapSolver.Utilities;
using Newtonsoft.Json;

namespace CapSolver.Models.Responses;

public class VisionEngineClassificationResponse : ITaskResponse
{
[JsonProperty("distance")]
public int Distance { get; set; }

[JsonProperty("angle")]
public int Angle{ get; set; }

[JsonProperty("box")]
public IList<float>? Box { get; set; }
}
Loading