diff --git a/src/mail/mail_reader.py b/src/mail/mail_reader.py index f86834d..9fb1e5c 100644 --- a/src/mail/mail_reader.py +++ b/src/mail/mail_reader.py @@ -139,6 +139,14 @@ def need_to_valid_url(url: str, successful_items) -> bool: return False +def need_to_check_email(mail: str, successful_items) -> bool: + for item in successful_items: + if item.email == mail: + if item.url_validated is not None: + return not item.url_validated + return True + + def read_mails(): # get email address mail_list = MONGO_STORE_MANAGER.get_destination_emails() @@ -154,8 +162,10 @@ def read_mails(): mails_messages = [] with ThreadPoolExecutor(max_workers=20) as executor: for mail in mail_list: - mail_reader = MailReader(mail.mail, mail.password) - executor.submit(mail_reader.read_emails, mails_messages) + # check whether we need to read mail + if need_to_check_email(mail, successful_items): + mail_reader = MailReader(mail.mail, mail.password) + executor.submit(mail_reader.read_emails, mails_messages) with ThreadPoolExecutor(max_workers=20) as executor: for mail in mails_messages: diff --git a/src/workers/commandor_page.py b/src/workers/commandor_page.py index a4278eb..c7c0a2c 100644 --- a/src/workers/commandor_page.py +++ b/src/workers/commandor_page.py @@ -10,6 +10,8 @@ import time import traceback from typing import Union +from playwright_stealth import stealth_sync + from src import params, definitions from src.db.mongo_manager import MONGO_STORE_MANAGER from src.params import get_random_wait_time @@ -170,6 +172,7 @@ class CommandorPage: }}); } """) + stealth_sync(self.page) self.page.on("load", self._on_page_loaded) self.page.on("response", self.handle_response) self.page.goto(RDV_URL, timeout=PAGE_TIMEOUT)