Skip to content

Commit

Permalink
[Audio] Fix attachment suffix reading on playlist upload w/ urllib (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Flame442 authored Dec 29, 2023
1 parent 76abb7c commit d322d91
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions redbot/cogs/audio/core/commands/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from io import BytesIO
from pathlib import Path
from urllib.parse import urlparse
from typing import cast

import discord
Expand Down Expand Up @@ -1823,7 +1824,7 @@ async def command_playlist_upload(
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.")
Expand All @@ -1848,7 +1849,7 @@ async def command_playlist_upload(
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 (
Expand Down

0 comments on commit d322d91

Please sign in to comment.