From 66c4526d120b52ba8cf6a53196477b99d4cffaca Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 25 Aug 2024 15:50:20 +0200 Subject: fix(downloader): Fallback to calculating the video size, before using hardcoded value --- src/download/mod.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/download/mod.rs b/src/download/mod.rs index faf4f37..b2d0b06 100644 --- a/src/download/mod.rs +++ b/src/download/mod.rs @@ -245,6 +245,13 @@ impl Downloader { val } else if let Some(val) = result.filesize_approx { val + } else if result.duration.is_some() && result.tbr.is_some() { + let duration = result.duration.expect("Is some").ceil() as u64; + + // TODO: yt_dlp gets this from the format + let tbr = result.tbr.expect("Is Some").ceil() as u64; + + duration * tbr * (1000 / 8) } else { let hardcoded_default = Bytes::from_str("250 MiB").expect("This is hardcoded"); error!( -- cgit 1.4.1