-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Description
To modify the code to handle the <enclosure> tag as the image part, you can update the logic within the update method. Specifically, you can check for the presence of the tag and extract the url attribute as the image URL.
# Check for the enclosure tag
if "enclosures" in entry:
enclosure = entry["enclosures"][0] # Assuming only one enclosure
entry_value["image"] = enclosure.get("url", "")
if not entry_value.get("image"):
# If there's no enclosure, check for image in summary
images = []
if "summary" in entry:
images = re.findall(
r"<img.+?src=\"(.+?)\".+?>", entry["summary"]
)
if images:
entry_value["image"] = images[0]
else:
entry_value[
"image"
] = "https://www.home-assistant.io/images/favicon-192x192-full.png"
This modification checks for the presence of the enclosures key in the entry. If it exists, it assumes there is at least one enclosure, and it extracts the url attribute from the first enclosure as the image URL. If there is no enclosure, it falls back to the previous logic of checking for an image in the summary.
Metadata
Metadata
Assignees
Labels
No labels