From 5638cbda332f0cb4d2bc5bfefac5a3ab3d01366e Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sun, 25 Aug 2024 15:55:15 +0200 Subject: feat(cli): Support the common select -> download -> watch workflow --- src/main.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 7febefc..304b99f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,6 +23,7 @@ use storage::video_database::getters::get_video_by_hash; use tokio::{ fs::File, io::{stdin, BufReader}, + task::JoinHandle, }; use url::Url; use yt_dlp::wrapper::info_json::InfoJson; @@ -106,6 +107,26 @@ async fn main() -> Result<()> { _ => handle_select_cmd(&app, cmd, None).await?, } } + Command::SeDoWa {} => { + select::select(&app, false, false).await?; + + let max_cache_size = app.config.download.max_cache_size; + info!("Max cache size: '{}'", max_cache_size); + + let arc_app = Arc::new(app); + + let arc_app_clone = Arc::clone(&arc_app); + let download: JoinHandle> = tokio::spawn(async move { + download::Downloader::new() + .consume(arc_app_clone, max_cache_size.as_u64()) + .await?; + + Ok(()) + }); + + watch::watch(&arc_app).await?; + download.await??; + } Command::Videos { cmd } => match cmd { VideosCommand::List { search_query, -- cgit 1.4.1