Deduplicate YouTube videos

master
Nikola Forró 4 years ago
parent 8ca86f2234
commit 244b7a92bd

@ -59,6 +59,7 @@ class Bot(discord.Client):
re.compile(r'^(?P<prefix>!)(?P<command>reaction)\s+(?P<q>")?(?P<query>.+)(?(q)")$'),
)
self.youtube = YouTube(yt_api_key, yt_channel_id)
self.yt_videos = []
super().__init__()
async def process_event(self, service, data):
@ -140,6 +141,11 @@ class Bot(discord.Client):
video = self.youtube.get_video(video_id)
except YouTubeError as e:
return
published = entry.get('published')
if published:
if [v for v, p in self.yt_videos if v == video_id and p == published]:
return
self.yt_videos.append((video_id, published))
channel = self.get_channel(youtube_channel_id)
if channel:
note = ''

Loading…
Cancel
Save