diff --git a/redbot/cogs/streams/streams.py b/redbot/cogs/streams/streams.py index f490bc5ce..33d63a486 100644 --- a/redbot/cogs/streams/streams.py +++ b/redbot/cogs/streams/streams.py @@ -724,6 +724,7 @@ class Streams(commands.Cog): stream._messages_cache.append(m) async def check_streams(self): + to_remove = [] for stream in self.streams: try: try: @@ -738,6 +739,10 @@ class Streams(commands.Cog): else: embed = await stream.is_online() + except StreamNotFound: + log.info("Stream with name %s no longer exists. Removing...", stream.name) + to_remove.append(stream) + continue except OfflineStream: if not stream._messages_cache: continue @@ -818,6 +823,11 @@ class Streams(commands.Cog): except Exception as e: log.error("An error has occured with Streams. Please report it.", exc_info=e) + if to_remove: + for stream in to_remove: + self.streams.remove(stream) + await self.save_streams() + async def _get_mention_str( self, guild: discord.Guild, channel: discord.TextChannel ) -> Tuple[str, List[discord.Role]]: diff --git a/redbot/cogs/streams/streamtypes.py b/redbot/cogs/streams/streamtypes.py index cab177cd6..0847b00ba 100644 --- a/redbot/cogs/streams/streamtypes.py +++ b/redbot/cogs/streams/streamtypes.py @@ -106,6 +106,8 @@ class YoutubeStream(Stream): async with aiohttp.ClientSession() as session: async with session.get(YOUTUBE_CHANNEL_RSS.format(channel_id=self.id)) as r: + if r.status == 404: + raise StreamNotFound() rssdata = await r.text() if self.not_livestreams: