mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-07 11:48:55 -05:00
[Streams] Fetch APIs with utf-8 encoding (#642)
This commit is contained in:
parent
343fc80406
commit
acc86d08db
@ -316,7 +316,7 @@ class Streams:
|
|||||||
url = "https://api.hitbox.tv/media/live/" + stream
|
url = "https://api.hitbox.tv/media/live/" + stream
|
||||||
try:
|
try:
|
||||||
async with aiohttp.get(url) as r:
|
async with aiohttp.get(url) as r:
|
||||||
data = await r.json()
|
data = await r.json(encoding='utf-8')
|
||||||
if "livestream" not in data:
|
if "livestream" not in data:
|
||||||
return None
|
return None
|
||||||
if data["livestream"][0]["media_is_live"] == "0":
|
if data["livestream"][0]["media_is_live"] == "0":
|
||||||
@ -334,7 +334,7 @@ class Streams:
|
|||||||
header = {'Client-ID': self.settings.get("TWITCH_TOKEN", "")}
|
header = {'Client-ID': self.settings.get("TWITCH_TOKEN", "")}
|
||||||
try:
|
try:
|
||||||
async with session.get(url, headers=header) as r:
|
async with session.get(url, headers=header) as r:
|
||||||
data = await r.json()
|
data = await r.json(encoding='utf-8')
|
||||||
await session.close()
|
await session.close()
|
||||||
if r.status == 400:
|
if r.status == 400:
|
||||||
return 400
|
return 400
|
||||||
@ -353,7 +353,7 @@ class Streams:
|
|||||||
url = "https://beam.pro/api/v1/channels/" + stream
|
url = "https://beam.pro/api/v1/channels/" + stream
|
||||||
try:
|
try:
|
||||||
async with aiohttp.get(url) as r:
|
async with aiohttp.get(url) as r:
|
||||||
data = await r.json()
|
data = await r.json(encoding='utf-8')
|
||||||
if "online" in data:
|
if "online" in data:
|
||||||
if data["online"] is True:
|
if data["online"] is True:
|
||||||
data = self.beam_embed(data)
|
data = self.beam_embed(data)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user