use utf-8 to decode pl emails
This commit is contained in:
+13
-11
@@ -141,13 +141,15 @@ class MailReader():
|
||||
for part in email_message.walk():
|
||||
print(part.get_content_type())
|
||||
if part.get_content_type() == "text/html":
|
||||
body = body + part.get_payload()
|
||||
body = body + part.get_payload(decode=True).decode("utf-8")
|
||||
elif part.get_content_type() == "text/plain":
|
||||
body = body + part.get_payload()
|
||||
if VALIDATION_URL_SUBJECT_fr in subject or VALIDATION_URL_SUBJECT_EN in subject:
|
||||
mail = MailPojo(subject=subject, body=body, from_address=from_address)
|
||||
mail.isImapClient = True
|
||||
print("email is {}".format(self.login))
|
||||
print("body is {}".format(body))
|
||||
print("subject is {}".format(subject))
|
||||
mail_messages.append(mail)
|
||||
except Exception as error:
|
||||
print(error)
|
||||
@@ -196,17 +198,17 @@ def need_to_check_email(mail: str, successful_items) -> bool:
|
||||
|
||||
def read_mails():
|
||||
# check time before start checking emails
|
||||
if is_time_between(time(7, 30), time(19, 30)):
|
||||
if is_time_between(time(7, 30), time(23, 30)):
|
||||
# get email address
|
||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||
# mail_address1 = MailAddress(mail="enasremor1973@onet.pl", password=")ozBUE0RjZ8N")
|
||||
# mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||
mail_address1 = MailAddress(mail="enasremor1973@onet.pl", password=")ozBUE0RjZ8N")
|
||||
# mail_address1 = MailAddress(mail="chenpeijun@aol.com", password="ytifuwguknzifqyb")
|
||||
# # mail_address2 = MailAddress(mail="sdfgfhgf1986@aol.com", password="fjwcgvhxxlywqfwm")
|
||||
# # mail_address3 = MailAddress(mail="ciyuexie@aol.com", password="czezlmmyypokdfce")
|
||||
# # mail_address4 = MailAddress(mail="hongjiang176@aol.com", password="ftzpscgzvwneelmn")
|
||||
# mail_address4 = MailAddress(mail="ryan_meacham2856@yahoo.com", password="ulgggkodxqbvrpgm")
|
||||
# mail_list = [mail_address3, mail_address2, mail_address1, mail_address4]
|
||||
# mail_list = [mail_address1]
|
||||
mail_list = [mail_address1]
|
||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
mails_messages = []
|
||||
with ThreadPoolExecutor(max_workers=200) as executor:
|
||||
@@ -218,15 +220,15 @@ def read_mails():
|
||||
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for mail in mails_messages:
|
||||
if mail.isImapClient:
|
||||
match = re.search(PART_VALIDATION_URL_REGEX, mail.body.replace("\n", ""))
|
||||
else:
|
||||
# if mail.isImapClient:
|
||||
# match = re.search(PART_VALIDATION_URL_REGEX, mail.body.replace("\n", ""))
|
||||
# else:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
if match:
|
||||
url_to_validate = match.group(0)
|
||||
if mail.isImapClient:
|
||||
url = "https://rendezvousparis.hermes.com/" + url_to_validate.replace("3D", "")
|
||||
else:
|
||||
# if mail.isImapClient:
|
||||
# url = "https://rendezvousparis.hermes.com/" + url_to_validate.replace("3D", "")
|
||||
# else:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, successful_items):
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url)
|
||||
|
||||
Reference in New Issue
Block a user