aboutsummaryrefslogtreecommitdiffstats
path: root/src/videos/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/videos/mod.rs
parentfix(downloader): Don't display changed cache size on first run (diff)
downloadyt-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 'src/videos/mod.rs')
-rw-r--r--src/videos/mod.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/videos/mod.rs b/src/videos/mod.rs
index 3876bd1..59baa8c 100644
--- a/src/videos/mod.rs
+++ b/src/videos/mod.rs
@@ -9,12 +9,15 @@
// If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
use anyhow::Result;
+use display::{format_video::FormatVideo, FormattedVideo};
use futures::{stream::FuturesUnordered, TryStreamExt};
use nucleo_matcher::{
pattern::{CaseMatching, Normalization, Pattern},
Matcher,
};
+pub mod display;
+
use crate::{
app::App,
storage::video_database::{getters::get_videos, VideoStatus},
@@ -25,7 +28,7 @@ pub async fn query(app: &App, limit: Option<usize>, search_query: Option<String>
// turn one video to a color display, to pre-warm the hash shrinking cache
if let Some(val) = all_videos.first() {
- val.to_color_display(app).await?;
+ val.to_formatted_video(app).await?;
}
let limit = limit.unwrap_or(all_videos.len());
@@ -33,10 +36,13 @@ pub async fn query(app: &App, limit: Option<usize>, search_query: Option<String>
let all_video_strings: Vec<String> = all_videos
.into_iter()
.take(limit)
- .map(|vid| vid.to_color_display_owned(app))
+ .map(|vid| vid.to_formatted_video_owned(app))
.collect::<FuturesUnordered<_>>()
- .try_collect()
- .await?;
+ .try_collect::<Vec<FormattedVideo>>()
+ .await?
+ .into_iter()
+ .map(|vid| (&vid.colorize()).to_line_display())
+ .collect();
if let Some(query) = search_query {
let mut matcher = Matcher::new(nucleo_matcher::Config::DEFAULT.match_paths());