From 145a776039248a9460e9473e4bc9ef3d533b60c1 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 14 Oct 2024 12:32:23 +0200 Subject: 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. --- src/update/mod.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/update/mod.rs') 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(()) } } -- cgit 1.4.1