From dddf79cd0e1ac1c79d10d9802bf90ee1600e16aa Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 10 Feb 2020 21:57:10 +0900 Subject: Allow starting afresh with a new ID3v2.3 tag --- src/id3v2.rs | 2 +- src/main.rs | 10 ++++++++++ src/options.rs | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/id3v2.rs b/src/id3v2.rs index b427845..f65260d 100644 --- a/src/id3v2.rs +++ b/src/id3v2.rs @@ -50,7 +50,7 @@ fn encode_string(s: &str) -> io::Result> { #[derive(Debug)] pub struct ID3v2 { header_size: usize, - version_sub: u8, // ID3v2.{} + pub version_sub: u8, // ID3v2.{} pub frames: Vec, } diff --git a/src/main.rs b/src/main.rs index 5af6eb1..7c8b34c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,6 +19,10 @@ fn parse_options_into(opt: &mut Options) { .add_option(&["-w", "--write"], StoreTrue, "Write updated information instead of just displaying. Unmodified or unknown tags are preserved as-is."); + ap.refer(&mut opt.clean) + .add_option(&["--clean"], StoreTrue, + "Remove any existing fields in ID3v2.* tag, and convert to ID3v2.3 (pending commit with --write)"); + ap.refer(&mut opt.latin1_as_utf8) .add_option(&["--assume-utf8"], StoreTrue, "Assume that all strings specified in the MP3 as Latin-1 are really UTF-8."); @@ -122,6 +126,12 @@ fn main() -> io::Result<()> { tag }; + if options.clean { + tag.frames.clear(); + tag.version_sub = 3; + eprintln!("NOTE: Removed all existing fields and set version sub to 3 (to make an ID3v2.3 tag)"); + } + if options.latin1_as_utf8 { for frame in &mut tag.frames { if let Some(new_frame) = diff --git a/src/options.rs b/src/options.rs index b2223de..2dbf7a6 100644 --- a/src/options.rs +++ b/src/options.rs @@ -3,6 +3,7 @@ pub struct Options { pub remove_v1: bool, pub file: String, pub write: bool, + pub clean: bool, pub set_tags: TagOptions, } @@ -22,6 +23,7 @@ impl Default for Options { remove_v1: false, file: String::new(), write: false, + clean: false, set_tags: Default::default(), } } -- cgit v1.2.3