delete recognized images

This commit is contained in:
Lei PAN
2023-10-19 16:28:12 +02:00
parent c9bdd3ac31
commit 409b719abf
+16
View File
@@ -97,8 +97,12 @@ class OCRChecker {
.recognize(screenShot, config)
console.log(result)
if (result.includes(MESSAGE_URL_VALIDATION_EN) || result.includes(MESSAGE_URL_VALIDATION_FR) || result.includes(MESSAGE_URL_VALIDATION_FR_2)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.SUCCESS
} else if (result.includes(MESSAGE_FILL_FIELD_FR) || result.includes(MESSAGE_FILL_FIELD_FR_2) || result.includes(MESSAGE_FILL_FIELD_FR_3) || result.includes(MESSAGE_FILL_FIELD_FR_4) || result.includes(MESSAGE_FILL_FIELD_FR_5)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.FILL_FIELD
} else if (result.includes(CAPTCHA_ERROR_MESSAGE) || result.includes(CAPTCHA_ERROR_MESSAGE_FR)) {
return OCRResult.RECAPTCHA_ERROR
@@ -109,16 +113,26 @@ class OCRChecker {
} else if (result.includes(ERR_CACHE_MISS) || result.includes(ERR_CACHE_MISS_2) || result.includes(ERR_CACHE_MISS_3) || result.includes(ERR_CACHE_MISS_4)) {
return OCRResult.TO_REFRESH
} else if (result.includes(CHECKING_MSG_FR) || result.includes(CHECKING_MSG_FR_2)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.RECHECK
} else if (result.includes(SLIDING_CAPTCHA_FR) || result.includes(SLIDING_CAPTCHA_FR_2) || result.includes(SLIDING_CAPTCHA_FR_3) || result.includes(SLIDING_CAPTCHA_FR_4)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
// if (result.includes("rac"))
// return OCRResult.SLIDING_CAPTCHA_REFRESH
return OCRResult.SLIDING_CAPTCHA
} else if (result.includes(WELCOME_MESSAGE_FR)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.NEED_TO_CLICK_LATE_BTN
} else if (result.includes(GOOGLE_DISCONNECT_FR) || result.includes(GOOGLE_DISCONNECT_FR_1)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.GOOGLE_DISCONNECT
} else if (result.toLowerCase().includes(ONLINE_APPOINTMENT.toLowerCase())) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.ONLINE_APPOINTMENT
} else if (result.includes(PAGE_OPTIMIZATION_CHROME_FR) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_2) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_3)
|| result.includes(PAGE_OPTIMIZATION_CHROME_FR_4) || result.includes(PAGE_OPTIMIZATION_CHROME_FR_5)
@@ -130,6 +144,8 @@ class OCRChecker {
await this.deleteFile(screenShot)
return OCRResult.PAGE_OPTIMIZATION
} else if (result.includes(CONFIRM_RESEND_FORM_FR)) {
await this.deleteFile(fileName)
await this.deleteFile(screenShot)
return OCRResult.CONFIRM_RESEND_FORM
} else if (result.includes(CLOSED_MESSAGE_FR)) {
return OCRResult.CLOSED