mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 13:40:27 +02:00
feat: Update metadata handling to include chapter count and normalize keys for ffmpeg arguments
This commit is contained in:
@@ -189,11 +189,12 @@ def _build_metadata_payload(
|
||||
metadata = {
|
||||
"TITLE": title,
|
||||
"ARTIST": authors_text,
|
||||
"ALBUM": f"{title} ({chapter_count} {chapter_label})",
|
||||
"ALBUM": title,
|
||||
"YEAR": metadata_source.publication_year or now_year,
|
||||
"ALBUM_ARTIST": authors_text,
|
||||
"COMPOSER": "Narrator",
|
||||
"GENRE": "Audiobook",
|
||||
"CHAPTER_COUNT": str(chapter_count),
|
||||
}
|
||||
if metadata_source.publisher:
|
||||
metadata["PUBLISHER"] = metadata_source.publisher
|
||||
@@ -201,7 +202,10 @@ def _build_metadata_payload(
|
||||
metadata["COMMENT"] = metadata_source.description
|
||||
if metadata_source.language:
|
||||
metadata["LANGUAGE"] = metadata_source.language
|
||||
return _normalize_metadata_keys(metadata)
|
||||
normalized = _normalize_metadata_keys(metadata)
|
||||
# Ensure chapter_count survives normalization even if upstream metadata provided it
|
||||
normalized.setdefault("chapter_count", str(chapter_count))
|
||||
return normalized
|
||||
|
||||
|
||||
def _extract_pdf(path: Path) -> ExtractionResult:
|
||||
|
||||
@@ -334,7 +334,12 @@ def _metadata_to_ffmpeg_args(metadata: Dict[str, Any]) -> List[str]:
|
||||
key_str = str(key).strip()
|
||||
if not key_str:
|
||||
continue
|
||||
args.extend(["-metadata", f"{key_str}={value}"])
|
||||
normalized_key = key_str.lower()
|
||||
if normalized_key == "year":
|
||||
ffmpeg_key = "date"
|
||||
else:
|
||||
ffmpeg_key = key_str
|
||||
args.extend(["-metadata", f"{ffmpeg_key}={value}"])
|
||||
return args
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user