File tree 1 file changed +13
-7
lines changed
custom_components/feedparser
1 file changed +13
-7
lines changed Original file line number Diff line number Diff line change 31
31
CONF_SHOW_TOPN = "show_topn"
32
32
33
33
DEFAULT_SCAN_INTERVAL = timedelta (hours = 1 )
34
+ DEFAULT_THUMBNAIL = "https://www.home-assistant.io/images/favicon-192x192-full.png"
34
35
35
36
PLATFORM_SCHEMA = PLATFORM_SCHEMA .extend (
36
37
{
@@ -127,17 +128,22 @@ def update(self):
127
128
entry_value [key ] = value
128
129
129
130
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 = []
135
139
if images :
136
- entry_value ["image" ] = images [0 ]
140
+ entry_value ["image" ] = images [0 ][
141
+ "href"
142
+ ] # pick the first image found
137
143
else :
138
144
entry_value [
139
145
"image"
140
- ] = "https://www.home-assistant.io/images/favicon-192x192-full.png"
146
+ ] = DEFAULT_THUMBNAIL # use default image if no image found
141
147
142
148
self ._entries .append (entry_value )
143
149
You can’t perform that action at this time.
0 commit comments