summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-02-10 13:57:10 +0100
committerTom Smeding <tom.smeding@gmail.com>2020-02-10 13:57:10 +0100
commitdddf79cd0e1ac1c79d10d9802bf90ee1600e16aa (patch)
treebedf1b6fefb9675edd6811333b0883b023c4f59a
parent38b258bea2c6fc003ecb0e741b71c7b01fdeca77 (diff)
Allow starting afresh with a new ID3v2.3 tag
-rw-r--r--src/id3v2.rs2
-rw-r--r--src/main.rs10
-rw-r--r--src/options.rs2
3 files changed, 13 insertions, 1 deletions
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<Vec<u8>> {
#[derive(Debug)]
pub struct ID3v2 {
header_size: usize,
- version_sub: u8, // ID3v2.{}
+ pub version_sub: u8, // ID3v2.{}
pub frames: Vec<RawFrame>,
}
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(),
}
}