blob: 6760ee76f2ea465377e1cf2ee65f733621e3a908 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
use std::io;
use std::fs::File;
use argparse::{ArgumentParser, StoreTrue, Store};
use crate::options::{EncodingOptions, Options};
mod encoding;
mod error;
mod id3v2;
mod options;
mod util;
fn main() -> io::Result<()> {
let options = {
let mut options: Options = Default::default();
{
let mut ap = ArgumentParser::new();
ap.set_description("ID3v2 tag editor/fixer. Incomplete/work-in-progress.");
ap.refer(&mut options.latin1_as_utf8)
.add_option(&["--assume-utf8"], StoreTrue,
"Assume that all strings specified as Latin-1 are really UTF-8.");
ap.refer(&mut options.file)
.required()
.add_argument("file", Store,
"File to operate on (probably a .mp3)");
ap.parse_args_or_exit();
}
options
};
let mut f = File::open(options.file)?;
let tag = id3v2::ID3v2::from_stream(&mut f)?;
println!("{:?}", tag);
for frame in tag.frames {
println!("{:?}", frame.interpret(&EncodingOptions { latin1_as_utf8: options.latin1_as_utf8 }));
}
Ok(())
}
|