about summary refs log tree commit diff stats
path: root/src/update/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/update/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/update/mod.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/update/mod.rs b/src/update/mod.rs
index ce3a7f9..6abb8c4 100644
--- a/src/update/mod.rs
+++ b/src/update/mod.rs
@@ -29,6 +29,7 @@ use crate::{
             VideoStatus,
         },
     },
+    videos::display::format_video::FormatVideo,
 };
 
 pub async fn update(
@@ -103,7 +104,9 @@ pub async fn update(
 
         for (url, value) in output_json {
             let sub = back_subs.get(&url).expect("This was stored before");
-            process_subscription(app, sub, value, &hashes).await?
+            process_subscription(app, sub, value, &hashes)
+                .await
+                .with_context(|| format!("Failed to process subscription: '{}'", sub.name))?
         }
     }
 
@@ -237,8 +240,18 @@ async fn process_subscription(
         // We already stored the video information
         unreachable!("The python update script should have never provided us a duplicated video");
     } else {
-        println!("{}", video.to_color_display(app).await?);
-        add_video(app, video).await?;
+        add_video(app, video.clone())
+            .await
+            .with_context(|| format!("Failed to add video to database: '{}'", video.title))?;
+        println!(
+            "{}",
+            (&video
+                .to_formatted_video(app)
+                .await
+                .with_context(|| format!("Failed to format video: '{}'", video.title))?
+                .colorize())
+                .to_line_display()
+        );
         Ok(())
     }
 }