Skip to content

Commit

Permalink
Fix instagram posts with non-utf8 captions
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Mar 12, 2024
1 parent ef53009 commit b259d86
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/instagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,10 @@ async def request(self, url: str):
async with self.session.get(
url, allow_redirects=False, headers={"User-Agent": "bot"}
) as response:
text = await response.text()
data = await response.read()
# because the world is not perfect, and a server that
# promises utf-8 will not actually return utf-8
text = data.decode("utf-8", "ignore")
return text

except aiohttp.ClientConnectorError as e:
Expand Down

0 comments on commit b259d86

Please sign in to comment.