feat: group authors by first character
This commit is contained in:
parent
84929351d9
commit
1dac8cc13a
2 changed files with 7 additions and 6 deletions
|
@ -78,12 +78,13 @@ fn rename_files(directory: &str, base: &str, args: &Arguments) -> Result<i32> {
|
|||
let (Some(title), Some(artist)) = (tag.title(), tag.artist()) else {
|
||||
continue;
|
||||
};
|
||||
let (bucket, _) = artist.split_at(1);
|
||||
let album = parse_album(&title);
|
||||
count += 1;
|
||||
let new_name = if album.is_empty() {
|
||||
format!("{artist}/{title}/{title}.m4b")
|
||||
format!("{bucket}/{artist}/{title}/{title}.m4b")
|
||||
} else {
|
||||
build_series_name(&artist, &album, &title)
|
||||
build_series_name(bucket, &artist, &album, &title)
|
||||
};
|
||||
println!("==============================");
|
||||
println!("- artist: {artist}");
|
||||
|
@ -107,10 +108,10 @@ fn rename_files(directory: &str, base: &str, args: &Arguments) -> Result<i32> {
|
|||
Ok(count)
|
||||
}
|
||||
|
||||
fn build_series_name(artist: &str, album: &str, title: &str) -> String {
|
||||
fn build_series_name(bucket: &str, artist: &str, album: &str, title: &str) -> String {
|
||||
let index = parse_index(title);
|
||||
let title = parse_title(title);
|
||||
format!("{artist}/{album}/{index}. {title}/{index}. {title}.m4b")
|
||||
format!("{bucket}/{artist}/{album}/{index}. {title}/{index}. {title}.m4b")
|
||||
}
|
||||
|
||||
fn parse_index(title: &str) -> String {
|
||||
|
|
|
@ -11,8 +11,8 @@ use pretty_assertions::assert_eq;
|
|||
"3. A Conjuring of Light"
|
||||
)]
|
||||
fn parse_series_details(#[case] album: &str, #[case] title: &str, #[case] expected: &str) {
|
||||
let expected_result = format!("Bob/{album}/{expected}/{expected}.m4b");
|
||||
let result = build_series_name("Bob", album, title);
|
||||
let expected_result = format!("B/Bob/{album}/{expected}/{expected}.m4b");
|
||||
let result = build_series_name("B", "Bob", album, title);
|
||||
|
||||
assert_eq!(result, expected_result);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue