From fd48878c10d5648ccbb6d4f8ab6810230d112990 Mon Sep 17 00:00:00 2001 From: aandrew-me Date: Tue, 26 Jul 2022 10:30:46 +0600 Subject: [PATCH] Fixing file sizes --- public/index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/public/index.js b/public/index.js index 1a84e29..63932ac 100644 --- a/public/index.js +++ b/public/index.js @@ -36,10 +36,7 @@ function getInfo() { videoToggle.style.backgroundColor = "rgb(67, 212, 164)"; for (let format of data.formats) { - let sizeSplitted = (Number(format.contentLength) / 1000000) - .toString().split(".") - let size = sizeSplitted[0] + sizeSplitted[1].slice(0,1) - + let size = (Number(format.contentLength) / 1000000).toFixed(2) size = size + " MB"; // For videos @@ -63,7 +60,8 @@ function getInfo() { } // For audios - else { + else if(format.hasAudio && !format.hasVideo && format.audioBitrate) + { const pattern = /^mp*4a[0-9.]+$/g; let audioCodec; const itag = format.itag;