mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
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:
parent
7c8dba27f9
commit
94eb75e204
@ -48,7 +48,7 @@ const getApproxSize = async (command, videoUrl) => {
|
|||||||
if (!isNaN(sizeInBytes)) {
|
if (!isNaN(sizeInBytes)) {
|
||||||
return sizeInBytes / (1024 * 1024);
|
return sizeInBytes / (1024 * 1024);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid size received from yt-dlp');
|
return 0;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
@ -83,7 +83,7 @@ module.exports = (bot) => {
|
|||||||
|
|
||||||
if (fs.existsSync(ytDlpPath)) {
|
if (fs.existsSync(ytDlpPath)) {
|
||||||
const approxSizeInMB = await Promise.race([
|
const approxSizeInMB = await Promise.race([
|
||||||
getApproxSize(ytDlpPath, videoUrl)
|
getApproxSize(ytDlpPath, videoUrl),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await ctx.telegram.editMessageText(
|
await ctx.telegram.editMessageText(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user