kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
⚡️ Improve robustness
rodzic
c29a5f3fdd
commit
e98f740f1a
|
@ -126,14 +126,16 @@ export async function getOpenAIAuth({
|
||||||
await delay(500)
|
await delay(500)
|
||||||
|
|
||||||
// click login button and wait for navigation to finish
|
// click login button and wait for navigation to finish
|
||||||
await Promise.all([
|
while (page.url().endsWith('/auth/login')) {
|
||||||
page.waitForNavigation({
|
await Promise.all([
|
||||||
waitUntil: 'networkidle2',
|
page.waitForNavigation({
|
||||||
timeout: timeoutMs
|
waitUntil: 'networkidle2',
|
||||||
}),
|
timeout: timeoutMs
|
||||||
|
}),
|
||||||
page.click('#__next .btn-primary')
|
page.click('#__next .btn-primary')
|
||||||
])
|
])
|
||||||
|
delay(500)
|
||||||
|
}
|
||||||
|
|
||||||
await checkForChatGPTAtCapacity(page, { timeoutMs })
|
await checkForChatGPTAtCapacity(page, { timeoutMs })
|
||||||
|
|
||||||
|
@ -179,12 +181,22 @@ export async function getOpenAIAuth({
|
||||||
if (hasNopechaExtension) {
|
if (hasNopechaExtension) {
|
||||||
await waitForRecaptcha(page, { timeoutMs })
|
await waitForRecaptcha(page, { timeoutMs })
|
||||||
} else if (hasRecaptchaPlugin) {
|
} else if (hasRecaptchaPlugin) {
|
||||||
|
// Add retry for network unstable
|
||||||
console.log('solving captchas using 2captcha...')
|
console.log('solving captchas using 2captcha...')
|
||||||
const res = await page.solveRecaptchas()
|
const retries = 3
|
||||||
if (res.captchas?.length) {
|
for (let i = 0; i < retries; i++) {
|
||||||
console.log('captchas result', res)
|
try {
|
||||||
} else {
|
const res = await page.solveRecaptchas()
|
||||||
console.log('no captchas found')
|
if (res.captchas?.length) {
|
||||||
|
console.log('captchas result', res)
|
||||||
|
break
|
||||||
|
} else {
|
||||||
|
console.log('no captchas found')
|
||||||
|
delay(500)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('captcha error', e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue