From a1cc088b6aa06159f7aaff79e5ca2096a39e92a0 Mon Sep 17 00:00:00 2001 From: Will Tekulve Date: Thu, 12 May 2016 22:00:27 -0400 Subject: [PATCH] Disable YT search, working on fix --- cogs/audio.py | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/cogs/audio.py b/cogs/audio.py index 0dd66a69f..3e615a160 100644 --- a/cogs/audio.py +++ b/cogs/audio.py @@ -21,12 +21,6 @@ __version__ = "0.0.1" log = logging.getLogger("red.audio") log.setLevel(logging.DEBUG) -__author__ = "tekulvw" -__version__ = "0.0.1" - -log = logging.getLogger("red.audio") -log.setLevel(logging.DEBUG) - try: import youtube_dl except: @@ -195,6 +189,8 @@ class Downloader(threading.Thread): self.url = "https://youtube.com/watch?v={}".format( video["entries"][0]["id"]) + video.url = self.url + self.song = Song(**video) @@ -1068,14 +1064,14 @@ class Audio: await self.bot.say("I'm already downloading a file!") return - if caller != "yt_search": - if not self._valid_playable_url(url): - await self.bot.say("That's not a valid URL.") - return - else: + if caller == "yt_search": url = "[SEARCH:]" + url - self._clear_queue(server) + elif not self._valid_playable_url(url): + await self.bot.say("That's not a valid URL.") + return + self._stop_player(server) + self._clear_queue(server) self._add_to_queue(server, url) @commands.command(pass_context=True, no_pm=True) @@ -1108,19 +1104,6 @@ class Audio: else: await self.bot.say("Not playing anything on this server.") - @commands.command(pass_context=True, no_pm=True) - async def sing(self, ctx): - """Makes Red sing one of her songs""" - ids = ("zGTkAVsrfg8", "cGMWL8cOeAU", "vFrjMq4aL-g", "WROI5WYBU_A", - "41tIUr_ex3g", "f9O2Rjn1azc") - url = "https://www.youtube.com/watch?v={}".format(choice(ids)) - await self.play.callback(self, ctx, url) - - @commands.command(name="yt", pass_context=True, no_pm=True) - async def yt_search(self, ctx, *, search_terms: str): - """Searches and plays a video from YouTube""" - await self.play.callback(self, ctx, search_terms) - @commands.group(pass_context=True, no_pm=True) async def playlist(self, ctx): """Playlist management/control.""" @@ -1360,6 +1343,14 @@ class Audio: else: await self.bot.say("Can't skip if I'm not playing.") + @commands.command(pass_context=True, no_pm=True) + async def sing(self, ctx): + """Makes Red sing one of her songs""" + ids = ("zGTkAVsrfg8", "cGMWL8cOeAU", "vFrjMq4aL-g", "WROI5WYBU_A", + "41tIUr_ex3g", "f9O2Rjn1azc") + url = "https://www.youtube.com/watch?v={}".format(choice(ids)) + await self.play.callback(self, ctx, url) + @commands.command(pass_context=True, no_pm=True) async def song(self, ctx): """Info about the current song.""" @@ -1385,6 +1376,12 @@ class Audio: self._stop(server) + @commands.command(name="yt", pass_context=True, no_pm=True) + async def yt_search(self, ctx, *, search_terms: str): + """Searches and plays a video from YouTube""" + await self.bot.say('This got broken. Will be fixed soon.') + # await self.play.callback(self, ctx, search_terms) + def is_playing(self, server): if not self.voice_connected(server): return False