Skip to content

Commit 62643bd

Browse files
committed
2025.4.16
2 parents 6492e28 + 7695cf7 commit 62643bd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/m4b_util/helpers/splitter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ def split(
4444
if segment.title:
4545
cmd.extend(["-metadata", f"title={segment.title}"])
4646

47+
# Make sure to add the track number
48+
cmd.extend(["-metadata", f"track={i + 1}/{len(segment_list)}"])
49+
4750
# Add padding at the end of the segment
4851
if padding > 0.0:
4952
cmd.extend(["-af", f"apad=pad_dur={padding}"])

tests/helpers/test_splitter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ def check_func(input_file_path):
103103
testhelpers.check_output_folder(output_path=output_path, expected_files=expected_files, check_func=check_func)
104104

105105

106-
def test_title_metadata(silences_file_path, tmp_path):
106+
def test_metadata(silences_file_path, tmp_path):
107107
"""Split a file into four parts with custom title names."""
108108
def check_func(input_file_path):
109+
track_number = int(input_file_path.stem.split("_")[-1]) + 1
109110
probe = ffprobe.run_probe(input_file_path)
110-
assert input_file_path.stem == probe.tags["title"]
111+
assert probe.tags["title"] == input_file_path.stem
112+
assert probe.tags["track"] == f"{track_number}/4"
111113
output_path = tmp_path / "output"
112114
segment_list = [
113115
SegmentData(id=0, start_time=0.0, end_time=2.5, title="segment_0000"),

0 commit comments

Comments
 (0)