mirror of
https://github.com/maubot/rss.git
synced 2025-01-08 06:18:02 -05:00
Fix possible feed reading errors
This commit is contained in:
parent
e92d8fceb9
commit
8a769bbe18
@ -118,9 +118,16 @@ class RSSBot(Plugin):
|
|||||||
async def read_feed(self, url: str) -> str:
|
async def read_feed(self, url: str) -> str:
|
||||||
try:
|
try:
|
||||||
resp = await self.http.get(url)
|
resp = await self.http.get(url)
|
||||||
except aiohttp.client_exceptions.ClientError:
|
except Exception:
|
||||||
|
self.log.exception(f"Error fetching {url}")
|
||||||
return ""
|
return ""
|
||||||
|
try:
|
||||||
content = await resp.text()
|
content = await resp.text()
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
try:
|
||||||
|
content = await resp.text(encoding="utf-8")
|
||||||
|
except:
|
||||||
|
content = str(await resp.read())[2:-1]
|
||||||
return content
|
return content
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user