From d322d91a18d162e53a4e92a78716dd2edace54bd Mon Sep 17 00:00:00 2001 From: Michael Oliveira <34169552+Flame442@users.noreply.github.com> Date: Fri, 29 Dec 2023 16:11:27 -0500 Subject: [PATCH] [Audio] Fix attachment suffix reading on playlist upload w/ urllib (#6280) --- redbot/cogs/audio/core/commands/playlists.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/audio/core/commands/playlists.py b/redbot/cogs/audio/core/commands/playlists.py index 746b45881..b654828f8 100644 --- a/redbot/cogs/audio/core/commands/playlists.py +++ b/redbot/cogs/audio/core/commands/playlists.py @@ -7,6 +7,7 @@ import time from io import BytesIO from pathlib import Path +from urllib.parse import urlparse from typing import cast import discord @@ -1823,7 +1824,7 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass): file_url = file_message.attachments[0].url except IndexError: return await self.send_embed_msg(ctx, title=_("Upload cancelled.")) - file_suffix = file_url.rsplit(".", 1)[1] + file_suffix = urlparse(file_url).path.rsplit(".", 1)[1] if file_suffix != "txt": return await self.send_embed_msg( ctx, title=_("Only Red playlist files can be uploaded.") @@ -1848,7 +1849,7 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass): if len(track_list) > 10000: return await self.send_embed_msg(ctx, title=_("This playlist is too large.")) uploaded_playlist_name = uploaded_playlist.get( - "name", (file_url.split("/")[6]).split(".")[0] + "name", (urlparse(file_url).path.split("/")[-1]).rsplit(".", 1)[0] ) try: if self.api_interface is not None and (