From d1a4cbd4887f8e60eba9517e28fdb877c1d140fe Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 1 Nov 2022 08:36:41 -0700 Subject: [PATCH 1/2] fix: fix error with processing new format --- custom_components/mail_and_packages/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index ceee4c17..4e8bd93a 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -650,13 +650,15 @@ def get_mails( found_images = soup.find_all(id="mailpiece-image-src-id") if not found_images: continue + if "data:image/jpeg;base64" not in part: + _LOGGER.warning("Unexpected html format found.") + continue _LOGGER.debug("Found images: %s", bool(found_images)) # Convert all the images to binary data for image in found_images: filename = random_filename() data = str(image["src"]).split(",")[1] - _LOGGER.debug("Data: %s", data) try: with open( image_output_path + filename, "wb" From 00deb15da63ecf9d95b6ee840e57a88132dac55c Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 1 Nov 2022 08:41:15 -0700 Subject: [PATCH 2/2] linting --- custom_components/mail_and_packages/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/mail_and_packages/helpers.py b/custom_components/mail_and_packages/helpers.py index 4e8bd93a..785dbaea 100644 --- a/custom_components/mail_and_packages/helpers.py +++ b/custom_components/mail_and_packages/helpers.py @@ -652,7 +652,7 @@ def get_mails( continue if "data:image/jpeg;base64" not in part: _LOGGER.warning("Unexpected html format found.") - continue + continue _LOGGER.debug("Found images: %s", bool(found_images)) # Convert all the images to binary data