mirror of
https://github.com/nexy7574/LCC-bot.git
synced 2024-09-19 18:16:34 +01:00
Fix file size in output fix fix
This commit is contained in:
parent
357f0f9edf
commit
f4ce92bec0
1 changed files with 5 additions and 5 deletions
|
@ -756,7 +756,7 @@ class OtherCog(commands.Cog):
|
||||||
with tempfile.TemporaryDirectory(prefix="jimmy-ytdl-") as tempdir:
|
with tempfile.TemporaryDirectory(prefix="jimmy-ytdl-") as tempdir:
|
||||||
video_format = video_format.lower()
|
video_format = video_format.lower()
|
||||||
OUTPUT_FILE = str(Path(tempdir) / f"{ctx.user.id}.%(ext)s")
|
OUTPUT_FILE = str(Path(tempdir) / f"{ctx.user.id}.%(ext)s")
|
||||||
MAX_SIZE = ctx.guild.filesize_limit / 1024 ** 2
|
MAX_SIZE = ctx.guild.filesize_limit / 1024 / 1024
|
||||||
options = [
|
options = [
|
||||||
"--no-colors",
|
"--no-colors",
|
||||||
"--no-playlist",
|
"--no-playlist",
|
||||||
|
@ -813,7 +813,7 @@ class OtherCog(commands.Cog):
|
||||||
formats = data["formats"]
|
formats = data["formats"]
|
||||||
paginator = commands.Paginator()
|
paginator = commands.Paginator()
|
||||||
for fmt in formats:
|
for fmt in formats:
|
||||||
fs = round(fmt.get("filesize", len(fmt.get("fragments", [1]))) / 1024 ** 2, 1)
|
fs = round((fmt.get("filesize") or len(fmt.get("fragments", [b'\0'])) * 10) / 1024 / 1024, 1)
|
||||||
paginator.add_line(
|
paginator.add_line(
|
||||||
"* {0[format_id]}:\n"
|
"* {0[format_id]}:\n"
|
||||||
"\t- Encoding: {0[vcodec]} + {0[acodec]}\n"
|
"\t- Encoding: {0[vcodec]} + {0[acodec]}\n"
|
||||||
|
@ -835,7 +835,7 @@ class OtherCog(commands.Cog):
|
||||||
] if upload_log else []
|
] if upload_log else []
|
||||||
for file_name in Path(tempdir).glob(f"{ctx.user.id}.*"):
|
for file_name in Path(tempdir).glob(f"{ctx.user.id}.*"):
|
||||||
stat = file_name.stat()
|
stat = file_name.stat()
|
||||||
size_mb = stat.st_size / 1024 ** 2
|
size_mb = stat.st_size / 1024 / 1024
|
||||||
if size_mb > MAX_SIZE - 0.5:
|
if size_mb > MAX_SIZE - 0.5:
|
||||||
_x = io.BytesIO(
|
_x = io.BytesIO(
|
||||||
f"File {file_name.name} was too large ({size_mb:,.1f}MB vs {MAX_SIZE:.1f}MB)".encode()
|
f"File {file_name.name} was too large ({size_mb:,.1f}MB vs {MAX_SIZE:.1f}MB)".encode()
|
||||||
|
@ -960,8 +960,8 @@ class OtherCog(commands.Cog):
|
||||||
raise e
|
raise e
|
||||||
if size >= ctx.guild.filesize_limit - 1500:
|
if size >= ctx.guild.filesize_limit - 1500:
|
||||||
await _msg.edit(
|
await _msg.edit(
|
||||||
content=f"MP3 is too large ({size / 1024 ** 2}Mb vs "
|
content=f"MP3 is too large ({size / 1024 / 1024}Mb vs "
|
||||||
f"{ctx.guild.filesize_limit / 1024 ** 2}Mb)"
|
f"{ctx.guild.filesize_limit / 1024 / 1024}Mb)"
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
fn = ""
|
fn = ""
|
||||||
|
|
Loading…
Reference in a new issue