chore: set return 0 if approxsize is undefined for some cases

this fixes if user tries to download an Instagram video for example
This commit is contained in:
GiovaniFZ 2024-12-14 15:44:18 -03:00
parent 7c8dba27f9
commit 94eb75e204
No known key found for this signature in database
GPG Key ID: 63DD92181B575322

View File

@ -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(