about summary refs log tree commit diff stats
path: root/crates/yt/src/commands
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-07-24 16:12:07 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-07-24 16:12:07 +0200
commitca62bbb3e2455d4d832b4b359e7247deebf7f5c1 (patch)
tree7c916a4e25c459f5c3485197301cb312d6f9d2c0 /crates/yt/src/commands
parentfeat(crates/yt/commands/database): Init, to show the txn_log (diff)
downloadyt-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.rs9
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))?;
                         }