about summary refs log tree commit diff stats
path: root/src/select/mod.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-14 12:32:23 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-10-14 12:34:56 +0200
commit145a776039248a9460e9473e4bc9ef3d533b60c1 (patch)
tree7b2a948ae1f08335eba477c26bf1d5e83cdac24b /src/select/mod.rs
parentfix(downloader): Don't display changed cache size on first run (diff)
downloadyt-145a776039248a9460e9473e4bc9ef3d533b60c1.tar.gz
yt-145a776039248a9460e9473e4bc9ef3d533b60c1.zip
feat(videos): Provide a consistent display for the `Video` struct
Before, `Video`s where colourized differently, just because the
colourization was not standardized. It now is.
Diffstat (limited to '')
-rw-r--r--src/select/mod.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/select/mod.rs b/src/select/mod.rs
index 2663a04..ca7a203 100644
--- a/src/select/mod.rs
+++ b/src/select/mod.rs
@@ -20,6 +20,7 @@ use crate::{
     cli::CliArgs,
     constants::HELP_STR,
     storage::video_database::{getters::get_videos, VideoStatus},
+    videos::display::format_video::FormatVideo,
 };
 
 use anyhow::{bail, Context, Result};
@@ -63,23 +64,24 @@ pub async fn select(app: &App, done: bool, use_last_selection: bool) -> Result<(
         // Warmup the cache for the display rendering of the videos.
         // Otherwise the futures would all try to warm it up at the same time.
         if let Some(vid) = matching_videos.first() {
-            let _ = vid.to_select_file_display(app).await?;
+            let _ = vid.to_formatted_video(app).await?;
         }
 
         let mut edit_file = BufWriter::new(&temp_file);
 
         join_all(
             matching_videos
-                .iter()
-                .map(|vid| async { vid.to_select_file_display(app).await })
+                .into_iter()
+                .map(|vid| async { vid.to_formatted_video_owned(app).await })
                 .collect::<Vec<_>>(),
         )
         .await
         .into_iter()
         .try_for_each(|line| -> Result<()> {
-            let line = line?;
+            let formatted_line = (&line?).to_select_file_display();
+
             edit_file
-                .write_all(line.as_bytes())
+                .write_all(formatted_line.as_bytes())
                 .expect("This write should not fail");
 
             Ok(())