Skip to content

Commit b259d86

Browse files
committed
Fix instagram posts with non-utf8 captions
1 parent ef53009 commit b259d86

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

modules/instagram.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ async def request(self, url: str):
106106
async with self.session.get(
107107
url, allow_redirects=False, headers={"User-Agent": "bot"}
108108
) as response:
109-
text = await response.text()
109+
data = await response.read()
110+
# because the world is not perfect, and a server that
111+
# promises utf-8 will not actually return utf-8
112+
text = data.decode("utf-8", "ignore")
110113
return text
111114

112115
except aiohttp.ClientConnectorError as e:

0 commit comments

Comments
 (0)