Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix error with processing new format #741

Merged
merged 2 commits into from
Nov 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion custom_components/mail_and_packages/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down