From 11dede352ccc1b2e4675b3c0ce1c0d27a2992d11 Mon Sep 17 00:00:00 2001 From: Jason Shipp Date: Tue, 24 Dec 2024 03:24:17 -0500 Subject: [PATCH 1/3] Allow for multiple links in %play --- src/plutarch/commands/audio_player.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/plutarch/commands/audio_player.py b/src/plutarch/commands/audio_player.py index 4415edf..2e8e830 100644 --- a/src/plutarch/commands/audio_player.py +++ b/src/plutarch/commands/audio_player.py @@ -69,8 +69,10 @@ async def play_queued(self): # Commands @commands.command(name="play") - async def play(self, ctx: commands.Context, url: str): - self.logger.info("user %s requested to play %s", ctx.author.name, url) + async def play(self, ctx: commands.Context, url_input: str): + self.logger.info("user %s requested to play %s", ctx.author.name, url_input) + urls = url_input.split(" ") + url = url_input[0] channel = ctx.author.voice.channel player_state: PlayerChannelState channels_info = get_channels() @@ -92,7 +94,13 @@ async def play(self, ctx: commands.Context, url: str): source = await get_source(url) player_state.playing = url - await self._play(state, source) + task = asyncio.create_task(self._play(state, source)) + asyncio.sleep(0) + if len(urls): + await asyncio.gather( + *[self.queue(ctx, url) for url in urls[1:]] + ) + await task @commands.command(name="queue") async def queue(self, ctx: commands.Context, url: str): @@ -162,7 +170,7 @@ async def get_source(url: str): def search_youtube(query): - with YoutubeDL({"format": 'm4a/bestaudio/best', "noplaylist": "True"}) as ydl: + with YoutubeDL({"format": "m4a/bestaudio/best", "noplaylist": "True"}) as ydl: try: requests.get(query, timeout=30) except requests.exceptions.HTTPError: From 42201c472baf44a2ee34360551012d1f6db2488c Mon Sep 17 00:00:00 2001 From: Jason Shipp Date: Tue, 24 Dec 2024 03:55:43 -0500 Subject: [PATCH 2/3] try greedy --- src/plutarch/commands/audio_player.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plutarch/commands/audio_player.py b/src/plutarch/commands/audio_player.py index 2e8e830..7f16955 100644 --- a/src/plutarch/commands/audio_player.py +++ b/src/plutarch/commands/audio_player.py @@ -69,7 +69,7 @@ async def play_queued(self): # Commands @commands.command(name="play") - async def play(self, ctx: commands.Context, url_input: str): + async def play(self, ctx: commands.Context, url_input: commands.Greedy[str]): self.logger.info("user %s requested to play %s", ctx.author.name, url_input) urls = url_input.split(" ") url = url_input[0] @@ -97,9 +97,7 @@ async def play(self, ctx: commands.Context, url_input: str): task = asyncio.create_task(self._play(state, source)) asyncio.sleep(0) if len(urls): - await asyncio.gather( - *[self.queue(ctx, url) for url in urls[1:]] - ) + await asyncio.gather(*[self.queue(ctx, url) for url in urls[1:]]) await task @commands.command(name="queue") From 05882e698fdc55157449c0772369c79f931376af Mon Sep 17 00:00:00 2001 From: Jason Shipp Date: Sun, 29 Dec 2024 03:48:59 -0500 Subject: [PATCH 3/3] multi --- src/plutarch/commands/audio_player.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/plutarch/commands/audio_player.py b/src/plutarch/commands/audio_player.py index 7f16955..db03ca8 100644 --- a/src/plutarch/commands/audio_player.py +++ b/src/plutarch/commands/audio_player.py @@ -69,9 +69,8 @@ async def play_queued(self): # Commands @commands.command(name="play") - async def play(self, ctx: commands.Context, url_input: commands.Greedy[str]): + async def play(self, ctx: commands.Context, *url_input): self.logger.info("user %s requested to play %s", ctx.author.name, url_input) - urls = url_input.split(" ") url = url_input[0] channel = ctx.author.voice.channel player_state: PlayerChannelState @@ -96,8 +95,8 @@ async def play(self, ctx: commands.Context, url_input: commands.Greedy[str]): player_state.playing = url task = asyncio.create_task(self._play(state, source)) asyncio.sleep(0) - if len(urls): - await asyncio.gather(*[self.queue(ctx, url) for url in urls[1:]]) + if len(url_input) > 1: + await asyncio.gather(*[self.queue(ctx, url) for url in url_input[1:]]) await task @commands.command(name="queue")