about summary refs log tree commit diff stats
path: root/src/main.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 15:55:15 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 15:55:15 +0200
commit5638cbda332f0cb4d2bc5bfefac5a3ab3d01366e (patch)
tree0348a6ec8da2e4e8dd87d4d95ce0fcfc3a422404 /src/main.rs
parentrefactor(watch/playlist_handler): Init (diff)
downloadyt-5638cbda332f0cb4d2bc5bfefac5a3ab3d01366e.tar.gz
yt-5638cbda332f0cb4d2bc5bfefac5a3ab3d01366e.zip
feat(cli): Support the common select -> download -> watch workflow
Diffstat (limited to '')
-rw-r--r--src/main.rs21
1 files changed, 21 insertions, 0 deletions
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<Result<()>> = 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,