Skip to content

Commit b82ba77

Browse files
committed
fixed some bugs
1 parent 1afc765 commit b82ba77

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

acmethods.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
2626
return r
2727
}
2828

29-
createTask := func(task map[string]interface{}) (int, error) {
29+
createTask := func(task map[string]interface{}) (any, error) {
3030
d := domain()
3131

3232
payload := map[string]interface{}{
@@ -57,6 +57,11 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
5757
return 0, errors.New("no taskId")
5858
}
5959

60+
taskStr, ok := taskId.(string)
61+
if ok {
62+
return taskStr, nil
63+
}
64+
6065
return int(taskId.(float64)), nil
6166
}
6267

@@ -126,7 +131,7 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
126131
}
127132

128133
// keeps retrying until it has returned error or solved
129-
getResponse := func(taskId int) (*Solution, error) {
134+
getResponse := func(taskId any) (*Solution, error) {
130135
for {
131136
time.Sleep(solver.UpdateDelay)
132137

@@ -251,6 +256,10 @@ func antiCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
251256
taskData["userAgent"] = o.UserAgent
252257
}
253258

259+
if o.APIDomain != "" {
260+
taskData["apiDomain"] = o.APIDomain
261+
}
262+
254263
if o.Cookies != nil && len(o.Cookies) > 0 {
255264
taskData["cookies"] = cookiesToString(o.Cookies)
256265
}

captchas.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,15 @@ type RecaptchaV2Options struct {
145145
Invisible bool
146146
// Enterprise only works on some captcha services (optional)
147147
Enterprise map[string]interface{}
148+
// APIDomain is the domain of the recaptcha (optional)
149+
APIDomain string
148150
}
149151

150152
type Solution struct {
151-
Text string
152-
TaskId int
153+
Text string
154+
155+
// TaskId is normally a int, but can be a string depending on the service
156+
TaskId any
153157

154158
// RawSolution not supported on 2captcha methods
155159
RawSolution map[string]interface{}

tcmethods.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ func twoCaptchaMethods(solver *Solver, preferredDomain string) *solveMethods {
136136
payload["data-s"] = o.DataS
137137
}
138138

139+
if o.APIDomain != "" {
140+
payload["domain"] = o.APIDomain
141+
}
142+
143+
if o.Enterprise != nil {
144+
payload["enterprise"] = 1
145+
}
146+
139147
if o.Cookies != nil && len(o.Cookies) > 0 {
140148
payload["cookies"] = cookiesToString(o.Cookies)
141149
}

0 commit comments

Comments
 (0)