Cog-Creators / Red-DiscordBot

A multi-function Discord bot
https://docs.discord.red
GNU General Public License v3.0
4.81k stars 2.31k forks source link

[Streams] Errors After Update Fix (3.4.5) #4695

Open Menteroth opened 3 years ago

Menteroth commented 3 years ago

Getting this for Streams now instead after fix. It's every 5-6 minutes. So whenever it checks for live streams I guess.

https://hastebin.com/evitafozuj.sql

Injabie3 commented 3 years ago

+1, haven't looked into this one yet. I've seen this happen a few times in my instance but embeds still get posted.

I don't see the above paste anymore, so editing this with a recent snippet (please ignore the extra pprint import for debugging):

[11:35:40] ERROR    An error has occured with Streams. Please report it.                                                                                                                                                 [red.core.cogs.Streams]
                    ╭─────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────╮
                    │ /home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot-3.4.5-py3.8.egg/redbot/cogs/streams/streams.py:737 in check_streams                                                       │
                    │                                                                                                                                                                                                  │
                    │   734 │   │   │   │   │   │   embed, is_rerun = await stream.is_online()                                                                                                                         │
                    │   735 │   │   │   │   │                                                                                                                                                                          │
                    │   736 │   │   │   │   │   elif stream.__class__.__name__ == "YoutubeStream":                                                                                                                     │
                    │ ❱ 737 │   │   │   │   │   │   embed, is_schedule = await stream.is_online()                                                                                                                      │
                    │   738 │   │   │   │   │                                                                                                                                                                          │
                    │   739 │   │   │   │   │   else:                                                                                                                                                                  │
                    │   740 │   │   │   │   │   │   embed = await stream.is_online()                                                                                                                                   │
                    │                                                                                                                                                                                                  │
                    │ /home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot-3.4.5-py3.8.egg/redbot/cogs/streams/streamtypes.py:167 in is_online                                                       │
                    │                                                                                                                                                                                                  │
                    │   164 │   │   │   async with aiohttp.ClientSession() as session:                                                                                                                                 │
                    │   165 │   │   │   │   async with session.get(YOUTUBE_VIDEOS_ENDPOINT, params=params) as r:                                                                                                       │
                    │   166 │   │   │   │   │   data = await r.json()                                                                                                                                                  │
                    │ ❱ 167 │   │   │   return await self.make_embed(data)                                                                                                                                             │
                    │   168 │   │   raise OfflineStream()                                                                                                                                                              │
                    │   169 │                                                                                                                                                                                          │
                    │   170 │   async def make_embed(self, data):              '                                                                                                                                       │
                    │                                                                                                                                                                                                  │
                    │ /home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot-3.4.5-py3.8.egg/redbot/cogs/streams/streamtypes.py:173 in make_embed                                                      │
                    │                                                                                                                                                                                                  │
                    │   170 │   async def make_embed(self, data):                                                                                                                                                      │
                    │   171 │   │   from pprint import pprint                                                                                                                                                          │
                    │   172 │   │   pprint(data["items"])                                                                                                                                                              │
                    │ ❱ 173 │   │   vid_data = data["items"][0]                                                                                                                                                        │
                    │   174 │   │   video_url = "https://youtube.com/watch?v={}".format(vid_data["id"])                                                                                                                │
                    │   175 │   │   title = vid_data["snippet"]["title"]                                                                                                                                               │
                    │   176 │   │   thumbnail = vid_data["snippet"]["thumbnails"]["medium"]["url"]                                                                                                                     │
                    ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
                    IndexError: list index out of range
Injabie3 commented 3 years ago

This is a hard to reproduce issue. I sprinkled in a print on the params before we use it for a YT request. It appears this issue arises when the stream goes offline and is privated afterwards.

Attaching some logs with my API key scrubbed. The livestream in question was https://www.youtube.com/watch?v=8AenYrsL8_M

Edit: And some time between me posting this update and me editing this, this stream has been unprivated.

image

[2021-01-18 20:50:01] [DEBUG] red.cogs.mutes: Cleaning unmute tasks
[2021-01-18 20:50:01] [DEBUG] red.cogs.mutes: Checking server unmutes
[2021-01-18 20:50:01] [DEBUG] red.cogs.mutes: Checking channel unmutes
{'id': '3gpkqxvtppM',
 'key': 'xxxx',
 'part': 'snippet,liveStreamingDetails'}
{'id': '8AenYrsL8_M',
 'key': 'xxxx',
 'part': 'snippet,liveStreamingDetails'}
[2021-01-18 20:50:02] [ERROR] red.core.cogs.Streams: An error has occured with Streams. Please report it.
Traceback (most recent call last):
  File "/home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot-3.4.5-py3.8.egg/redbot/cogs/streams/streams.py", line 737, in check_streams
    embed, is_schedule = await stream.is_online()
  File "/home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot-3.4.5-py3.8.egg/redbot/cogs/streams/streamtypes.py", line 169, in is_online
    return await self.make_embed(data)
  File "/home/ubuntu/github/renchan/lib/python3.8/site-packages/Red_DiscordBot-3.4.5-py3.8.egg/redbot/cogs/streams/streamtypes.py", line 175, in make_embed
    vid_data = data["items"][0]
IndexError: list index out of range
{'id': 'lueGJGxj1ws',
 'key': 'xxxx',
 'part': 'snippet,liveStreamingDetails'}
[2021-01-18 20:50:04] [DEBUG] red.core.lavalink: [NODE] | Received Payload:: <{"op":"playerUpdate","state":{"position":589800,"time":1611031804647},"guildId":"xxx"}>