diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-07-24 16:12:07 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-07-24 16:12:07 +0200 |
commit | ca62bbb3e2455d4d832b4b359e7247deebf7f5c1 (patch) | |
tree | 7c916a4e25c459f5c3485197301cb312d6f9d2c0 /crates/yt/src/commands | |
parent | feat(crates/yt/commands/database): Init, to show the txn_log (diff) | |
download | yt-ca62bbb3e2455d4d832b4b359e7247deebf7f5c1.zip |
fix(crates/yt/{commands/playlist,videos/format_video}): Correctly calculate watch percent
Previously, they were using u64, which obviously only returned `0%`.
Diffstat (limited to 'crates/yt/src/commands')
-rw-r--r-- | crates/yt/src/commands/playlist/implm.rs | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/crates/yt/src/commands/playlist/implm.rs b/crates/yt/src/commands/playlist/implm.rs index 98a8e64..ce4b394 100644 --- a/crates/yt/src/commands/playlist/implm.rs +++ b/crates/yt/src/commands/playlist/implm.rs @@ -49,13 +49,8 @@ impl PlaylistCommand { if is_focused { output.push_str(" ("); - if let Some(duration) = video.duration.as_secs() { - let watch_progress: f64 = f64::from( - u32::try_from(video.watch_progress.as_secs()).expect("No overflow"), - ); - let duration = f64::from(u32::try_from(duration).expect("No overflow")); - - write!(output, "{:0.0}%", (watch_progress / duration) * 100.0)?; + if let Some(percent) = video.watch_progress_percent_fmt() { + write!(output, "{}", percent.to_string(app))?; } else { write!(output, "{}", video.watch_progress_fmt().to_string(app))?; } |