aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cli.rs3
-rw-r--r--src/main.rs21
2 files changed, 24 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs
index 42b6378..60b0772 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -61,6 +61,9 @@ pub enum Command {
max_cache_size: Option<u64>,
},
+ /// Select, download and watch in one command.
+ SeDoWa {},
+
/// Work with single videos
Videos {
#[command(subcommand)]
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,