mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[Audio] Fix attachment suffix reading on playlist upload w/ urllib (#6280)
This commit is contained in:
parent
76abb7cab2
commit
d322d91a18
@ -7,6 +7,7 @@ import time
|
|||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from urllib.parse import urlparse
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
@ -1823,7 +1824,7 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
file_url = file_message.attachments[0].url
|
file_url = file_message.attachments[0].url
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return await self.send_embed_msg(ctx, title=_("Upload cancelled."))
|
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":
|
if file_suffix != "txt":
|
||||||
return await self.send_embed_msg(
|
return await self.send_embed_msg(
|
||||||
ctx, title=_("Only Red playlist files can be uploaded.")
|
ctx, title=_("Only Red playlist files can be uploaded.")
|
||||||
@ -1848,7 +1849,7 @@ class PlaylistCommands(MixinMeta, metaclass=CompositeMetaClass):
|
|||||||
if len(track_list) > 10000:
|
if len(track_list) > 10000:
|
||||||
return await self.send_embed_msg(ctx, title=_("This playlist is too large."))
|
return await self.send_embed_msg(ctx, title=_("This playlist is too large."))
|
||||||
uploaded_playlist_name = uploaded_playlist.get(
|
uploaded_playlist_name = uploaded_playlist.get(
|
||||||
"name", (file_url.split("/")[6]).split(".")[0]
|
"name", (urlparse(file_url).path.split("/")[-1]).rsplit(".", 1)[0]
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
if self.api_interface is not None and (
|
if self.api_interface is not None and (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user