diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-13 21:01:06 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-06-13 21:01:06 +0200 |
commit | ec4e0c91d33b2a8c11b71d4cdb1edeaa44ce8247 (patch) | |
tree | 2907cf3825bb61c78e2ed69143dec48acc19d24c | |
parent | style(yt/cli): Sort the toplevel flags alphabetically (diff) | |
download | yt-ec4e0c91d33b2a8c11b71d4cdb1edeaa44ce8247.zip |
feat(yt/status): Show the percentage of videos that were actually watched
-rw-r--r-- | yt/src/status/mod.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/yt/src/status/mod.rs b/yt/src/status/mod.rs index bc45cfb..18bef7d 100644 --- a/yt/src/status/mod.rs +++ b/yt/src/status/mod.rs @@ -87,6 +87,15 @@ pub async fn show(app: &App) -> Result<()> { } }; + let watch_rate: f64 = { + fn to_f64(input: usize) -> f64 { + f64::from(u32::try_from(input).expect("This should never exceed u32::MAX")) + } + + let count = to_f64(watched_videos_len) / (to_f64(drop_videos_len) + to_f64(dropped_videos_len)); + count * 100.0 + }; + let cache_usage_raw = Downloader::get_current_cache_allocation(app) .await .context("Failed to get current cache allocation")?; @@ -97,7 +106,7 @@ Picked Videos: {picked_videos_len} Watch Videos: {watch_videos_len} Cached Videos: {cached_videos_len} -Watched Videos: {watched_videos_len} +Watched Videos: {watched_videos_len} (watch rate: {watch_rate:.2} %) Drop Videos: {drop_videos_len} Dropped Videos: {dropped_videos_len} |