Fix audio-only downloads

This commit is contained in:
Nexus 2024-01-24 21:17:37 +00:00
parent 6e04f4a97d
commit b815f96c2e

View file

@ -341,8 +341,23 @@ class YTDLCog(commands.Cog):
delete_after=120, delete_after=120,
) )
try: try:
file = next(temp_dir.glob("*." + extracted_info["ext"])) if audio_only is False:
file = next(temp_dir.glob("*." + extracted_info["ext"]))
else:
# can be .opus, .m4a, .mp3, .ogg, .oga
for _file in temp_dir.iterdir():
if _file.suffix in (".opus", ".m4a", ".mp3", ".ogg", ".oga", ".aac", ".wav"):
file = _file
break
else:
raise StopIteration
except StopIteration: except StopIteration:
self.log.warning(
"Failed to locate downloaded file. Was supposed to be looking for a file extension of "
"%r amongst files %r, however none were found.",
extracted_info["ext"],
list(map(str, temp_dir.iterdir()))
)
return await ctx.edit( return await ctx.edit(
embed=discord.Embed( embed=discord.Embed(
title="Error", title="Error",
@ -381,7 +396,7 @@ class YTDLCog(commands.Cog):
"-movflags", "-movflags",
"faststart", "faststart",
"-b:a", "-b:a",
"48k", "64k",
"-y", "-y",
"-strict", "-strict",
"2", "2",