mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Streams] Fix TypeError in TwitchStream class and change stream_alert function for Twitch (#3042)
* Update streamtypes.py * Create 3042.bugfix.rst * Black the things. * Fix Twitch streams alert and [p]streamalert twitch * Update 3042.bugfix.rst
This commit is contained in:
parent
42e3f73088
commit
743ce71c5c
1
changelog.d/streams/3042.bugfix.rst
Normal file
1
changelog.d/streams/3042.bugfix.rst
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix a TypeError in TwitchStream class when calling Twitch client_id from Red shared APIs tokens and also changed the stream_alert function for Twitch alerts to make it works with how TwitchStream class works now.
|
||||||
@ -275,8 +275,11 @@ class Streams(commands.Cog):
|
|||||||
if not stream:
|
if not stream:
|
||||||
token = await self.bot.get_shared_api_tokens(_class.token_name)
|
token = await self.bot.get_shared_api_tokens(_class.token_name)
|
||||||
is_yt = _class.__name__ == "YoutubeStream"
|
is_yt = _class.__name__ == "YoutubeStream"
|
||||||
|
is_twitch = _class.__name__ == "TwitchStream"
|
||||||
if is_yt and not self.check_name_or_id(channel_name):
|
if is_yt and not self.check_name_or_id(channel_name):
|
||||||
stream = _class(id=channel_name, token=token)
|
stream = _class(id=channel_name, token=token)
|
||||||
|
elif is_twitch:
|
||||||
|
stream = _class(name=channel_name, token=token.get("client_id"))
|
||||||
else:
|
else:
|
||||||
stream = _class(name=channel_name, token=token)
|
stream = _class(name=channel_name, token=token)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -162,10 +162,7 @@ class TwitchStream(Stream):
|
|||||||
self.id = await self.fetch_id()
|
self.id = await self.fetch_id()
|
||||||
|
|
||||||
url = TWITCH_STREAMS_ENDPOINT + self.id
|
url = TWITCH_STREAMS_ENDPOINT + self.id
|
||||||
header = {
|
header = {"Client-ID": str(self._token), "Accept": "application/vnd.twitchtv.v5+json"}
|
||||||
"Client-ID": str(self._token["client_id"]),
|
|
||||||
"Accept": "application/vnd.twitchtv.v5+json",
|
|
||||||
}
|
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
async with session.get(url, headers=header) as r:
|
async with session.get(url, headers=header) as r:
|
||||||
@ -187,10 +184,7 @@ class TwitchStream(Stream):
|
|||||||
raise APIError()
|
raise APIError()
|
||||||
|
|
||||||
async def fetch_id(self):
|
async def fetch_id(self):
|
||||||
header = {
|
header = {"Client-ID": str(self._token), "Accept": "application/vnd.twitchtv.v5+json"}
|
||||||
"Client-ID": str(self._token["client_id"]),
|
|
||||||
"Accept": "application/vnd.twitchtv.v5+json",
|
|
||||||
}
|
|
||||||
url = TWITCH_ID_ENDPOINT + self.name
|
url = TWITCH_ID_ENDPOINT + self.name
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
async with aiohttp.ClientSession() as session:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user