Skip to content

Commit

Permalink
added support for MEE6 notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
FirePlank committed Nov 6, 2023
1 parent df859e0 commit 3ffccf5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bot/extensions/youtube/tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import re
import xml.etree.ElementTree as ET
from datetime import datetime
from io import BytesIO
Expand All @@ -12,6 +13,8 @@
from bot import core
from bot.config import settings

YOUTUBE_URL = re.compile(r"(?P<url>https?://www\.youtube\.com/watch\?v=[\w-]+)")


class YoutubeTasks(commands.Cog):
"""Tasks for YouTube functions"""
Expand Down Expand Up @@ -49,10 +52,13 @@ async def check_for_new_videos(self):

if not self.videos:
async for message in self.channel.history(limit=10):
try:
if message.embeds:
self.videos.append(message.embeds[0].url)
except IndexError:
pass
else:
match = YOUTUBE_URL.search(message.content)
if match:
self.videos.append(match.group("url"))

self.videos.reverse()

url = "https://www.youtube.com/feeds/videos.xml?channel_id=UC4JX40jDee_tINbkjycV4Sg"
Expand Down

0 comments on commit 3ffccf5

Please sign in to comment.