mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 05:40:26 +02:00
feat: Add series sequence handling and normalization for Audiobookshelf metadata
This commit is contained in:
+62
-1
@@ -187,4 +187,65 @@ def test_audiobookshelf_metadata_uses_book_number(tmp_path):
|
||||
metadata = _build_audiobookshelf_metadata(job)
|
||||
|
||||
assert metadata["seriesName"] == "Example Saga"
|
||||
assert metadata["seriesSequence"] == "7"
|
||||
assert metadata["seriesSequence"] == "7"
|
||||
|
||||
|
||||
def test_audiobookshelf_metadata_normalizes_sequence_value(tmp_path):
|
||||
source = tmp_path / "book.txt"
|
||||
source.write_text("content", encoding="utf-8")
|
||||
|
||||
job = Job(
|
||||
id="job-abs-normalize",
|
||||
original_filename="book.txt",
|
||||
stored_path=source,
|
||||
language="en",
|
||||
voice="af_alloy",
|
||||
speed=1.0,
|
||||
use_gpu=False,
|
||||
subtitle_mode="Sentence",
|
||||
output_format="mp3",
|
||||
save_mode="Save next to input file",
|
||||
output_folder=tmp_path,
|
||||
replace_single_newlines=False,
|
||||
subtitle_format="srt",
|
||||
created_at=time.time(),
|
||||
metadata_tags={
|
||||
"series": "Example Saga",
|
||||
"series_index": "Book 7 of the Series",
|
||||
},
|
||||
)
|
||||
|
||||
metadata = _build_audiobookshelf_metadata(job)
|
||||
|
||||
assert metadata["seriesName"] == "Example Saga"
|
||||
assert metadata["seriesSequence"] == "7"
|
||||
|
||||
|
||||
def test_audiobookshelf_metadata_allows_decimal_sequence(tmp_path):
|
||||
source = tmp_path / "book.txt"
|
||||
source.write_text("content", encoding="utf-8")
|
||||
|
||||
job = Job(
|
||||
id="job-abs-decimal",
|
||||
original_filename="book.txt",
|
||||
stored_path=source,
|
||||
language="en",
|
||||
voice="af_alloy",
|
||||
speed=1.0,
|
||||
use_gpu=False,
|
||||
subtitle_mode="Sentence",
|
||||
output_format="mp3",
|
||||
save_mode="Save next to input file",
|
||||
output_folder=tmp_path,
|
||||
replace_single_newlines=False,
|
||||
subtitle_format="srt",
|
||||
created_at=time.time(),
|
||||
metadata_tags={
|
||||
"series": "Example Saga",
|
||||
"series_number": "Book 4.5",
|
||||
},
|
||||
)
|
||||
|
||||
metadata = _build_audiobookshelf_metadata(job)
|
||||
|
||||
assert metadata["seriesSequence"] == "4.5"
|
||||
Reference in New Issue
Block a user