allow editing artist name
This commit is contained in:
29
src/main.rs
29
src/main.rs
@@ -52,13 +52,18 @@ fn move_file(file: PathBuf, mut destination: PathBuf) {
|
||||
}
|
||||
}
|
||||
|
||||
fn yes() -> bool {
|
||||
fn user_input() -> String {
|
||||
let mut answer = String::new();
|
||||
|
||||
io::stdin().read_line(&mut answer)
|
||||
.expect("Failed to read input");
|
||||
|
||||
answer.to_lowercase().starts_with("y")
|
||||
answer
|
||||
}
|
||||
|
||||
// todo: add other input options e.g. "d" for delete, "a" for "yes to this whole album"
|
||||
fn yes() -> bool {
|
||||
user_input().to_lowercase().starts_with("y")
|
||||
}
|
||||
|
||||
fn handle_document(file: DirEntry) {
|
||||
@@ -91,16 +96,24 @@ fn handle_mp3(file: DirEntry) {
|
||||
|
||||
if meta.is_err() {
|
||||
println!("Couldn't read ID3 metadata for file {:?}", file.path());
|
||||
}
|
||||
} else if let Some(tag) = meta.unwrap().tag {
|
||||
let mut artist = tag.artist.trim().to_string();
|
||||
let album = tag.album.trim();
|
||||
let title = tag.title.trim();
|
||||
|
||||
if let Some(tag) = meta.unwrap().tag {
|
||||
println!("----------------------");
|
||||
println!("file: {:?}", file.path());
|
||||
println!("artist: {}", tag.artist.trim());
|
||||
println!("album: {}", tag.album.trim());
|
||||
println!("title: {}", tag.title.trim());
|
||||
println!("artist: {}", artist);
|
||||
println!("album: {}", album);
|
||||
println!("title: {}", title);
|
||||
|
||||
println!("move to: ~/Music/{}/{}/?", tag.artist.trim(), tag.album.trim());
|
||||
if artist.len() == 0 {
|
||||
println!("Enter artist name?");
|
||||
artist = user_input();
|
||||
// is there a way to update mp3 metadata here?
|
||||
}
|
||||
|
||||
println!("move to: ~/Music/{}/{}/?", artist.clone(), album);
|
||||
|
||||
if yes() {
|
||||
move_file(
|
||||
|
||||
Reference in New Issue
Block a user