mirror of
https://github.com/maubot/rss.git
synced 2025-04-15 21:13:08 -04:00
Pass raw data to feedparser. Fixes #59
This commit is contained in:
parent
68e5a84096
commit
72d08096b7
10
rss/bot.py
10
rss/bot.py
@ -257,15 +257,9 @@ class RSSBot(Plugin):
|
||||
async def _parse_rss(
|
||||
cls, feed: Feed, resp: aiohttp.ClientResponse
|
||||
) -> tuple[Feed, list[Entry]]:
|
||||
try:
|
||||
content = await resp.text()
|
||||
except UnicodeDecodeError:
|
||||
try:
|
||||
content = await resp.text(encoding="utf-8", errors="ignore")
|
||||
except UnicodeDecodeError:
|
||||
content = str(await resp.read())[2:-1]
|
||||
content = await resp.read()
|
||||
headers = {"Content-Location": feed.url, **resp.headers, "Content-Encoding": "identity"}
|
||||
parsed_data = feedparser.parse(io.StringIO(content), response_headers=headers)
|
||||
parsed_data = feedparser.parse(io.BytesIO(content), response_headers=headers)
|
||||
if parsed_data.bozo:
|
||||
if not isinstance(parsed_data.bozo_exception, feedparser.ThingsNobodyCaresAboutButMe):
|
||||
raise parsed_data.bozo_exception
|
||||
|
Loading…
x
Reference in New Issue
Block a user