File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
custom_components/feedparser Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 3131CONF_SHOW_TOPN = "show_topn"
3232
3333DEFAULT_SCAN_INTERVAL = timedelta (hours = 1 )
34+ DEFAULT_THUMBNAIL = "https://www.home-assistant.io/images/favicon-192x192-full.png"
3435
3536PLATFORM_SCHEMA = PLATFORM_SCHEMA .extend (
3637 {
@@ -127,17 +128,22 @@ def update(self):
127128 entry_value [key ] = value
128129
129130 if "image" in self ._inclusions and "image" not in entry_value .keys ():
130- images = []
131- if "summary" in entry .keys ():
132- images = re .findall (
133- r"<img.+?src=\"(.+?)\".+?>" , entry ["summary" ]
134- )
131+ if "enclosures" in entry :
132+ images = [
133+ enc
134+ for enc in entry ["enclosures" ]
135+ if enc .type .startswith ("image/" )
136+ ]
137+ else :
138+ images = []
135139 if images :
136- entry_value ["image" ] = images [0 ]
140+ entry_value ["image" ] = images [0 ][
141+ "href"
142+ ] # pick the first image found
137143 else :
138144 entry_value [
139145 "image"
140- ] = "https://www.home-assistant.io/images/favicon-192x192-full.png"
146+ ] = DEFAULT_THUMBNAIL # use default image if no image found
141147
142148 self ._entries .append (entry_value )
143149
You can’t perform that action at this time.
0 commit comments