|
1 | 1 | """Feedparser sensor"""
|
2 | 2 | from __future__ import annotations
|
3 | 3 |
|
4 |
| -import asyncio |
5 | 4 | import re
|
6 | 5 | from datetime import timedelta
|
7 | 6 |
|
| 7 | +import feedparser |
8 | 8 | import homeassistant.helpers.config_validation as cv
|
| 9 | +import homeassistant.util.dt as dt |
9 | 10 | import voluptuous as vol
|
10 | 11 | from dateutil import parser
|
11 |
| -from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity |
12 |
| -from homeassistant.const import CONF_NAME, CONF_SCAN_INTERVAL |
| 12 | +from homeassistant.components.sensor import PLATFORM_SCHEMA |
| 13 | +from homeassistant.components.sensor import SensorEntity |
| 14 | +from homeassistant.const import CONF_NAME |
| 15 | +from homeassistant.const import CONF_SCAN_INTERVAL |
13 | 16 | from homeassistant.core import HomeAssistant
|
14 | 17 | from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
15 |
| -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType |
16 |
| -import homeassistant.util.dt as dt |
17 |
| - |
18 |
| -import feedparser |
| 18 | +from homeassistant.helpers.typing import ConfigType |
| 19 | +from homeassistant.helpers.typing import DiscoveryInfoType |
19 | 20 |
|
20 | 21 | __version__ = "0.1.11"
|
21 | 22 |
|
|
25 | 26 |
|
26 | 27 | CONF_FEED_URL = "feed_url"
|
27 | 28 | CONF_DATE_FORMAT = "date_format"
|
28 |
| -CONF_LOCAL_TIME = "local_time" |
| 29 | +CONF_LOCAL_TIME = "local_time" |
29 | 30 | CONF_INCLUSIONS = "inclusions"
|
30 | 31 | CONF_EXCLUSIONS = "exclusions"
|
31 | 32 | CONF_SHOW_TOPN = "show_topn"
|
|
46 | 47 | )
|
47 | 48 |
|
48 | 49 |
|
49 |
| -"""@asyncio.coroutine""" |
50 | 50 | async def async_setup_platform(
|
51 | 51 | hass: HomeAssistant,
|
52 | 52 | config: ConfigType,
|
@@ -129,9 +129,7 @@ def update(self):
|
129 | 129 | if "image" in self._inclusions and "image" not in entry_value.keys():
|
130 | 130 | images = []
|
131 | 131 | if "summary" in entry.keys():
|
132 |
| - images = re.findall( |
133 |
| - r"<img.+?src=\"(.+?)\".+?>", entry["summary"] |
134 |
| - ) |
| 132 | + images = re.findall(r"<img.+?src=\"(.+?)\".+?>", entry["summary"]) |
135 | 133 | if images:
|
136 | 134 | entry_value["image"] = images[0]
|
137 | 135 | else:
|
|
0 commit comments