Compare commits

..

No commits in common. "main" and "v0.3.0" have entirely different histories.
main ... v0.3.0

6 changed files with 33 additions and 69 deletions

View file

@ -1,22 +0,0 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [0.3.1](https://git.kemitix.net/kemitix/refile-m4b/compare/v0.3.0...v0.3.1) - 2024-10-12
### Added
- group authors by first character
### Other
- add usage instructions to readme
- fix name of project refile-mp4 to refile-m4b
- Back out "chore: reset version to allow forgejo workflow to bump it correctly"
- bump rstest from 0.22 to 0.23
- reset version to allow forgejo workflow to bump it correctly

48
Cargo.lock generated
View file

@ -65,6 +65,18 @@ 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"
@ -303,34 +315,22 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.87"
version = "1.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.37"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "refile-m4b"
version = "0.3.1"
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.23.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a2c585be59b6b5dd66a9d2084aa1d8bd52fbdb806eafdeffb52791147862035"
checksum = "7b423f0e62bdd61734b67cd21ff50871dfaeb9cc74f869dcd6af974fbcb19936"
dependencies = [
"futures",
"futures-timer",
@ -380,9 +380,9 @@ dependencies = [
[[package]]
name = "rstest_macros"
version = "0.23.0"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "825ea780781b15345a146be27eaefb05085e337e869bff01b4306a4fd4a9ad5a"
checksum = "c5e1711e7d14f74b12a58411c542185ef7fb7f2e7f8ee6e2940a883628522b42"
dependencies = [
"cfg-if",
"glob",
@ -428,9 +428,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "2.0.79"
version = "2.0.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a"
dependencies = [
"proc-macro2",
"quote",
@ -475,9 +475,9 @@ dependencies = [
[[package]]
name = "unicode-ident"
version = "1.0.13"
version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c"
[[package]]
name = "utf8parse"

View file

@ -1,6 +1,6 @@
[package]
name = "refile-m4b"
version = "0.3.1"
name = "refile-mp4"
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."
license = "MIT"
@ -15,4 +15,4 @@ taglib = "1.0.0"
[dev-dependencies]
pretty_assertions = "1.4"
rstest = "0.23"
rstest = "0.22"

View file

@ -1,14 +1,3 @@
# 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
@ -16,5 +5,3 @@ The information in each files metadata is used.
```bash
sudo apt install libtag1-dev libtagc0-dev
```
> Due to a typo, this was previously known as refile-mp4.

View file

@ -78,13 +78,12 @@ 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!("{bucket}/{artist}/{title}/{title}.m4b")
format!("{artist}/{title}/{title}.m4b")
} else {
build_series_name(bucket, &artist, &album, &title)
build_series_name(&artist, &album, &title)
};
println!("==============================");
println!("- artist: {artist}");
@ -108,10 +107,10 @@ fn rename_files(directory: &str, base: &str, args: &Arguments) -> Result<i32> {
Ok(count)
}
fn build_series_name(bucket: &str, artist: &str, album: &str, title: &str) -> String {
fn build_series_name(artist: &str, album: &str, title: &str) -> String {
let index = parse_index(title);
let title = parse_title(title);
format!("{bucket}/{artist}/{album}/{index}. {title}/{index}. {title}.m4b")
format!("{artist}/{album}/{index}. {title}/{index}. {title}.m4b")
}
fn parse_index(title: &str) -> String {

View file

@ -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!("B/Bob/{album}/{expected}/{expected}.m4b");
let result = build_series_name("B", "Bob", album, title);
let expected_result = format!("Bob/{album}/{expected}/{expected}.m4b");
let result = build_series_name("Bob", album, title);
assert_eq!(result, expected_result);
}