From 9a838458315fa85770ebe63bcea3c7d4a965e244 Mon Sep 17 00:00:00 2001 From: chaos Date: Fri, 20 Oct 2023 15:36:37 +0100 Subject: [PATCH] add feature for toggling replaygain support --- Cargo.toml | 5 ++++- src/commands/process.rs | 8 +++++++- src/utils/mod.rs | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 90f34b1..9eeaa48 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,6 +52,7 @@ notify = "6" [features] default = [ + "replaygain", "mp3_extractor", "flac_extractor", "taglib_extractor", @@ -65,4 +66,6 @@ flac_extractor = ["dep:metaflac"] mp3_extractor = ["dep:id3"] ffprobe_extractor = [] # If to allow using ffmpeg/ffprobe as a fallback tag extractor -command_genhtml = ["dep:html-escape", "dep:urlencoding"] \ No newline at end of file +command_genhtml = ["dep:html-escape", "dep:urlencoding"] + +replaygain = [] \ No newline at end of file diff --git a/src/commands/process.rs b/src/commands/process.rs index 55d6e08..fa96a7b 100644 --- a/src/commands/process.rs +++ b/src/commands/process.rs @@ -7,6 +7,7 @@ use crate::types::AudioFileInfo; use crate::types::File; use crate::utils::ascii_reduce::reduce_to_ascii; use crate::utils::formats::get_format_handler; +#[cfg(feature = "replaygain")] use crate::utils::replaygain::analyze_replaygain; use crate::utils::scan_for_music; @@ -15,10 +16,13 @@ pub struct ProcessCommandArgs { pub source: String, #[clap(long)] pub dry_run: bool, + #[cfg(feature = "replaygain")] #[clap(long)] pub skip_replaygain: bool, + #[cfg(feature = "replaygain")] #[clap(long)] pub force_replaygain: bool, + #[cfg(feature = "replaygain")] #[clap(long)] pub replaygain_threads: Option, #[clap(long)] @@ -112,6 +116,7 @@ fn rename_file(process_args: &ProcessCommandArgs, file: &mut File) { } } +#[cfg(feature = "replaygain")] pub fn add_replaygain_tags(file: &File, force: bool) -> Result<(), Box> { if !file.info.supports_replaygain { println!( @@ -210,7 +215,8 @@ pub fn process_command( for file in files.iter_mut() { rename_file(process_args, file); } - + + #[cfg(feature = "replaygain")] if !process_args.skip_replaygain && !process_args.dry_run { println!("Adding ReplayGain Tags to Files"); diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 3ba47d2..0789456 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,6 +1,7 @@ pub mod ascii_reduce; pub mod ffprobe; pub mod format_detection; +#[cfg(feature = "replaygain")] pub mod replaygain; pub mod transcoder;