add feature for toggling replaygain support

This commit is contained in:
chaos 2023-10-20 15:36:37 +01:00
parent 96117c2faf
commit 9a83845831
No known key found for this signature in database
3 changed files with 12 additions and 2 deletions

View file

@ -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"]
command_genhtml = ["dep:html-escape", "dep:urlencoding"]
replaygain = []

View file

@ -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<u32>,
#[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<dyn std::error::Error>> {
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");

View file

@ -1,6 +1,7 @@
pub mod ascii_reduce;
pub mod ffprobe;
pub mod format_detection;
#[cfg(feature = "replaygain")]
pub mod replaygain;
pub mod transcoder;