feat: group authors by first character
All checks were successful
Rust / build (map[name:stable]) (push) Successful in 1m48s
Rust / build (map[name:nightly]) (push) Successful in 3m46s
Release Please / Release-plz (push) Successful in 32s

This commit is contained in:
Paul Campbell 2024-10-11 22:39:18 +01:00
parent 84929351d9
commit 1dac8cc13a
2 changed files with 7 additions and 6 deletions

View file

@ -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 { let (Some(title), Some(artist)) = (tag.title(), tag.artist()) else {
continue; continue;
}; };
let (bucket, _) = artist.split_at(1);
let album = parse_album(&title); let album = parse_album(&title);
count += 1; count += 1;
let new_name = if album.is_empty() { let new_name = if album.is_empty() {
format!("{artist}/{title}/{title}.m4b") format!("{bucket}/{artist}/{title}/{title}.m4b")
} else { } else {
build_series_name(&artist, &album, &title) build_series_name(bucket, &artist, &album, &title)
}; };
println!("=============================="); println!("==============================");
println!("- artist: {artist}"); println!("- artist: {artist}");
@ -107,10 +108,10 @@ fn rename_files(directory: &str, base: &str, args: &Arguments) -> Result<i32> {
Ok(count) 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 index = parse_index(title);
let title = parse_title(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 { fn parse_index(title: &str) -> String {

View file

@ -11,8 +11,8 @@ use pretty_assertions::assert_eq;
"3. A Conjuring of Light" "3. A Conjuring of Light"
)] )]
fn parse_series_details(#[case] album: &str, #[case] title: &str, #[case] expected: &str) { fn parse_series_details(#[case] album: &str, #[case] title: &str, #[case] expected: &str) {
let expected_result = format!("Bob/{album}/{expected}/{expected}.m4b"); let expected_result = format!("B/Bob/{album}/{expected}/{expected}.m4b");
let result = build_series_name("Bob", album, title); let result = build_series_name("B", "Bob", album, title);
assert_eq!(result, expected_result); assert_eq!(result, expected_result);
} }