From 94eb75e204e24937a729aae355eaca0f8b3256b7 Mon Sep 17 00:00:00 2001 From: GiovaniFZ Date: Sat, 14 Dec 2024 15:44:18 -0300 Subject: [PATCH] chore: set return 0 if approxsize is undefined for some cases this fixes if user tries to download an Instagram video for example --- src/commands/youtube.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/youtube.js b/src/commands/youtube.js index 5ac86b3..4e124a4 100644 --- a/src/commands/youtube.js +++ b/src/commands/youtube.js @@ -48,7 +48,7 @@ const getApproxSize = async (command, videoUrl) => { if (!isNaN(sizeInBytes)) { return sizeInBytes / (1024 * 1024); } else { - throw new Error('Invalid size received from yt-dlp'); + return 0; } } catch (error) { throw error; @@ -83,7 +83,7 @@ module.exports = (bot) => { if (fs.existsSync(ytDlpPath)) { const approxSizeInMB = await Promise.race([ - getApproxSize(ytDlpPath, videoUrl) + getApproxSize(ytDlpPath, videoUrl), ]); await ctx.telegram.editMessageText(