Fix yt-dlp

This commit is contained in:
Nexus 2023-05-17 19:50:24 +01:00
parent c8d11c0f5a
commit 10292d0e17
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -928,7 +928,7 @@ class OtherCog(commands.Cog):
BYTES_REMAINING = (MAX_SIZE_MB - 0.256) * 1024 * 1024 BYTES_REMAINING = (MAX_SIZE_MB - 0.256) * 1024 * 1024
import yt_dlp import yt_dlp
with tempfile.TemporaryDirectory(prefix="jimmy-ytdl-wat") as tempdir_str: with tempfile.TemporaryDirectory(prefix="jimmy-ytdl-") as tempdir_str:
tempdir = Path(tempdir_str).resolve() tempdir = Path(tempdir_str).resolve()
stdout = tempdir / "stdout.txt" stdout = tempdir / "stdout.txt"
stderr = tempdir / "stderr.txt" stderr = tempdir / "stderr.txt"
@ -1020,7 +1020,14 @@ class OtherCog(commands.Cog):
st = file.stat().st_size st = file.stat().st_size
COMPRESS_FAILED = False COMPRESS_FAILED = False
if st / 1024 / 1024 >= MAX_SIZE_MB or st >= BYTES_REMAINING: if st / 1024 / 1024 >= MAX_SIZE_MB or st >= BYTES_REMAINING:
if compress_if_possible and file.suffix in (".mp4", ".mkv", ".mov"): if compress_if_possible and file.suffix in (
".mp4",
".mkv",
".mov",
'.aac',
'.opus',
'.webm'
):
await ctx.edit( await ctx.edit(
embed=discord.Embed( embed=discord.Embed(
title="Compressing...", title="Compressing...",
@ -1037,7 +1044,7 @@ class OtherCog(commands.Cog):
"-crf", "-crf",
"30", "30",
"-preset", "-preset",
"fast", "slow",
str(target) str(target)
] ]
@ -1085,9 +1092,9 @@ class OtherCog(commands.Cog):
await ctx.edit(embed=embed) await ctx.edit(embed=embed)
await ctx.channel.trigger_typing() await ctx.channel.trigger_typing()
embed.description = _desc embed.description = _desc
start = time.time() start = time()
await ctx.edit(embed=embed, files=files) await ctx.edit(embed=embed, files=files)
end = time.time() end = time()
if (end - start) < 10: if (end - start) < 10:
await ctx.respond("*clearing typing*", delete_after=0.01) await ctx.respond("*clearing typing*", delete_after=0.01)