From afd6f580e5864c7c2fd43d2db11b0134c1373c71 Mon Sep 17 00:00:00 2001 From: aikaterna <20862007+aikaterna@users.noreply.github.com> Date: Wed, 11 Mar 2020 09:19:16 -0700 Subject: [PATCH] [IcyParser] Allow a url to be specified --- icyparser/icyparser.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/icyparser/icyparser.py b/icyparser/icyparser.py index d919a5b..14dd40d 100644 --- a/icyparser/icyparser.py +++ b/icyparser/icyparser.py @@ -47,25 +47,28 @@ class IcyParser(commands.Cog): self.bot.loop.create_task(self.session.close()) @commands.command(aliases=["icynp"]) - async def icyparser(self, ctx): - """Show the now playing stream information, if any.""" - audiocog = self.bot.get_cog("Audio") - if not audiocog: - return await ctx.send("Audio is not loaded.") - try: - player = lavalink.get_player(ctx.guild.id) - except KeyError: - return await ctx.send("The bot is not playing any music.") - if not player.current: - return await ctx.send("The bot is not playing any music.") - if not player.current.is_stream: - return await ctx.send("The bot is not playing a stream.") - icy = await self._icyparser(player.current.uri) + async def icyparser(self, ctx, url=None): + """Show Icecast or Shoutcast stream information, if any.""" + if not url: + audiocog = self.bot.get_cog("Audio") + if not audiocog: + return await ctx.send("Audio is not loaded.") + try: + player = lavalink.get_player(ctx.guild.id) + except KeyError: + return await ctx.send("The bot is not playing any music.") + if not player.current: + return await ctx.send("The bot is not playing any music.") + if not player.current.is_stream: + return await ctx.send("The bot is not playing a stream.") + icy = await self._icyparser(player.current.uri) + else: + icy = await self._icyparser(url) if not icy[0]: return await ctx.send( - f"Can't read the stream information for <{player.current.uri}>, it may not be an Icecast or Shoutcast radio station or there may be no stream information available." + f"Can't read the stream information for <{player.current.uri if not url else url}>, it may not be an Icecast or Shoutcast radio station or there may be no stream information available." ) - song = f"**[{icy[0]}]({player.current.uri})**\n" + song = f"**[{icy[0]}]({player.current.uri if not url else url})**\n" embed = discord.Embed( colour=await ctx.embed_colour(), title="Now Playing", description=song )