Skip to content

Commit d8c351a

Browse files
committed
Add approx size calculation based on bitrate
1 parent 59d1f13 commit d8c351a

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/renderer.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,9 +1223,21 @@ class YtDownloaderApp {
12231223
let isAVideoSelected = false;
12241224

12251225
formats.forEach((format) => {
1226-
const size = format.filesize || format.filesize_approx;
1227-
const displaySize = size
1228-
? `${(size / 1000000).toFixed(2)} MB`
1226+
let sizeInMB = null;
1227+
let isApprox = false;
1228+
1229+
if (format.filesize) {
1230+
sizeInMB = format.filesize / 1000000;
1231+
} else if (format.filesize_approx) {
1232+
sizeInMB = format.filesize_approx / 1000000;
1233+
isApprox = true;
1234+
} else if (this.state.videoInfo.duration && format.tbr) {
1235+
sizeInMB = (this.state.videoInfo.duration * format.tbr) / 8192;
1236+
isApprox = true;
1237+
}
1238+
1239+
const displaySize = sizeInMB
1240+
? `${isApprox ? "~" : ""}${sizeInMB.toFixed(2)} MB`
12291241
: i18n.__("unknownSize");
12301242

12311243
if (format.video_ext !== "none" && format.vcodec !== "none") {

0 commit comments

Comments
 (0)