diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-23 13:58:40 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-23 13:58:40 +0200 |
commit | 86e9c745681a6cde96e1089b9a70f7cd2397a720 (patch) | |
tree | 6e45077a74f0d780be455ac95dbed36f715fc727 | |
parent | feat(watch/events): Add further understood script-messages (diff) | |
download | yt-86e9c745681a6cde96e1089b9a70f7cd2397a720.tar.gz yt-86e9c745681a6cde96e1089b9a70f7cd2397a720.zip |
fix(treewide): Actually use the values from the config
-rw-r--r-- | src/cli.rs | 21 | ||||
-rw-r--r-- | src/config/mod.rs | 2 | ||||
-rw-r--r-- | src/main.rs | 5 | ||||
-rw-r--r-- | src/select/cmds.rs | 5 |
4 files changed, 18 insertions, 15 deletions
diff --git a/src/cli.rs b/src/cli.rs index 05c78de..d3ec262 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -11,15 +11,12 @@ use std::path::PathBuf; use anyhow::Context; +use bytes::Bytes; use chrono::NaiveDate; use clap::{ArgAction, Args, Parser, Subcommand}; use url::Url; -use bytes::Bytes; use crate::{ - config::{ - default::{download, select, update}, - }, select::selection_file::duration::Duration, storage::video_database::extractor_hash::LazyExtractorHash, }; @@ -60,8 +57,8 @@ pub enum Command { /// The maximum size the download dir should have. Beware that the value must be given in /// bytes. - #[arg(short, long, default_value = download::max_cache_size(), value_parser = byte_parser)] - max_cache_size: u64, + #[arg(short, long, value_parser = byte_parser)] + max_cache_size: Option<u64>, }, /// Watch the already cached (and selected) videos @@ -96,9 +93,9 @@ pub enum Command { /// Update the video database Update { - #[arg(short, long, default_value_t = update::max_backlog() as u32)] + #[arg(short, long)] /// The number of videos to updating - max_backlog: u32, + max_backlog: Option<u32>, #[arg(short, long)] /// The subscriptions to update (can be given multiple times) @@ -200,12 +197,12 @@ pub enum SelectCommand { shared: SharedSelectionCommandArgs, /// The subtitles to download (e.g. 'en,de,sv') - #[arg(short = 'l', long, default_value = select::subtitle_langs())] - subtitle_langs: String, + #[arg(short = 'l', long)] + subtitle_langs: Option<String>, /// The speed to set mpv to - #[arg(short, long, default_value_t = select::playback_speed())] - speed: f64, + #[arg(short, long)] + speed: Option<f64>, }, /// Mark the video given by the hash to be dropped diff --git a/src/config/mod.rs b/src/config/mod.rs index 8ee7cc7..26d27eb 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -10,7 +10,7 @@ use std::path::PathBuf; -pub mod default; +mod default; pub mod file_system; pub struct Config { diff --git a/src/main.rs b/src/main.rs index a6766f6..a30dc24 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ async fn main() -> Result<()> { force, max_cache_size, } => { + let max_cache_size = max_cache_size.unwrap_or(app.config.download.max_cache_size); info!("max cache size: '{}'", max_cache_size); if force { @@ -97,7 +98,9 @@ async fn main() -> Result<()> { } } - update::update(&app, max_backlog, subscriptions, args.verbosity).await?; + let max_backlog = max_backlog.unwrap_or(app.config.update.max_backlog); + + update::update(&app, max_backlog, subscriptions, verbosity).await?; } Command::Subscriptions { cmd } => match cmd { diff --git a/src/select/cmds.rs b/src/select/cmds.rs index 85e655f..c480bd9 100644 --- a/src/select/cmds.rs +++ b/src/select/cmds.rs @@ -63,7 +63,10 @@ pub async fn handle_select_cmd( } => { let hash = shared.hash.realize(&app).await?; let video = get_video_by_hash(app, &hash).await?; - let video_options = VideoOptions::new(subtitle_langs, speed); + let video_options = VideoOptions::new( + subtitle_langs.unwrap_or(app.config.select.subtitle_langs.clone()), + speed.unwrap_or(app.config.select.playback_speed), + ); let priority = compute_priority(line_number, shared.priority); if let Some(_) = video.cache_path { |