From 673b66959ae57d67125bc6365f9db451fae30025 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Thu, 22 Dec 2016 11:47:28 -0600 Subject: [PATCH] Added an exception checking for youtube providing a error that makes sense (i.e. Copyright videos) --- cogs/music.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cogs/music.py b/cogs/music.py index 2544c63..5ebbc1b 100644 --- a/cogs/music.py +++ b/cogs/music.py @@ -290,8 +290,13 @@ class Music: song = info.get('entries', [])[0]['webpage_url'] _entry, position = await state.songs.add_entry(song, ctx.message.author) - if 'ytsearch' in info.get('url', ''): - print(info) + except ExtractionError as e: + # This gets the youtube_dl error, instead of our error raised + error = str(e).split("\n\n")[1] + # Youtube has a "fancy" colour error message it prints to the console + # Obviously this doesn't work in Discord, so just remove this + error = " ".join(error.split()[1:]) + await self.bot.send_message(ctx.message.channel, error) await self.bot.say('Enqueued ' + str(_entry)) @commands.command(pass_context=True, no_pm=True)