Compare commits
3 commits
d19aa1ae2c
...
1dac8cc13a
Author | SHA1 | Date | |
---|---|---|---|
1dac8cc13a | |||
84929351d9 | |||
ba0b72b4be |
5 changed files with 45 additions and 31 deletions
48
Cargo.lock
generated
48
Cargo.lock
generated
|
@ -65,18 +65,6 @@ version = "1.0.75"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
||||
|
||||
[[package]]
|
||||
name = "auto-file-mp4"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"pretty_assertions",
|
||||
"regex",
|
||||
"rstest",
|
||||
"taglib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
|
@ -315,22 +303,34 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.66"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
||||
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.33"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "refile-m4b"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"pretty_assertions",
|
||||
"regex",
|
||||
"rstest",
|
||||
"taglib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.10.6"
|
||||
|
@ -368,9 +368,9 @@ checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2"
|
|||
|
||||
[[package]]
|
||||
name = "rstest"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b423f0e62bdd61734b67cd21ff50871dfaeb9cc74f869dcd6af974fbcb19936"
|
||||
checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"futures-timer",
|
||||
|
@ -380,9 +380,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "rstest_macros"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c5e1711e7d14f74b12a58411c542185ef7fb7f2e7f8ee6e2940a883628522b42"
|
||||
checksum = "825ea780781b15345a146be27eaefb05085e337e869bff01b4306a4fd4a9ad5a"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"glob",
|
||||
|
@ -428,9 +428,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.29"
|
||||
version = "2.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
|
||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -475,9 +475,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.11"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "refile-mp4"
|
||||
name = "refile-m4b"
|
||||
version = "0.3.0"
|
||||
edition = "2021"
|
||||
description = "Refile a directory of m4b files by artist, album (where specified) and title. Used to refile m4b versions of converted aax files for use by Smart Audiobook Player."
|
||||
|
|
13
README.md
13
README.md
|
@ -1,3 +1,14 @@
|
|||
# Refile M4B
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
refile-m4b DIR
|
||||
```
|
||||
|
||||
This will refile all the `*.m4b` files in `DIR` and it's subdirectories by author, series (if given) and title.
|
||||
The information in each files metadata is used.
|
||||
|
||||
## dependencies
|
||||
|
||||
### debian
|
||||
|
@ -5,3 +16,5 @@
|
|||
```bash
|
||||
sudo apt install libtag1-dev libtagc0-dev
|
||||
```
|
||||
|
||||
> Due to a typo, this was previously known as refile-mp4.
|
||||
|
|
|
@ -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