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

Better handling images in enclosure tag #139

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions custom_components/feedparser/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ def _process_image(self: FeedParserSensor, feed_entry: FeedParserDict) -> str:
if images:
# pick the first image found
return images[0]
elif "enclosure" in feed_entry and feed_entry["enclosure"]:
enc = feed_entry["enclosure"] if feed_entry["enclosure"].type.startswith("image/") else None
if enc and "url" in enc:
return enc["url"]

_LOGGER.debug(
"Feed %s: Image is in inclusions, but no image was found for %s",
self.name,
Expand Down