Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added
- Support of case: one cue sheet, two files and many tracks.

## [0.1.1] - 2026-01-17

### Added
Expand Down
6 changes: 4 additions & 2 deletions cuesplitter/models/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from cuesplitter.ffmpeg import get_duration

MIN_TRACK_DURATION = 10 # (in seconds) Used to decide whether there are more tracks in the file or whether a new file should be started


class Track(TrackData):
duration: float # in seconds
Expand Down Expand Up @@ -48,11 +50,11 @@ async def _get_offset_duration(
offset = 0.0
if track_cue.index00 is not None:
offset = track_cue.index00.seconds
elif track_cue.index01 is not None:
else:
offset = track_cue.index01.seconds
duration = (
next_offset - offset
if next_offset is not None
if next_offset is not None and next_offset >= MIN_TRACK_DURATION
else await get_audiofile_duration(current_dir / track_cue.file) - offset
)
return offset, duration
Expand Down
37 changes: 34 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
from pathlib import Path
from typing import Any
import pytest

mock_durations = {
Path('/music/scorpions/Scorpions - Lonesome Crow.flac'): 28.0 * 60,
Path('/music/scorpions/01. Side A.flac'): 16.0 * 60,
Path('/music/scorpions/02. Side B.flac'): 16.0 * 60,
}


@pytest.fixture()
def cue_sample_for_durations():
return """REM GENRE Hard Rock
@pytest.fixture(
params=['one file many tracks', 'two files many tracks']
) # , 'one file one track'])
def cue_sample_for_durations(request: Any):
match request.param:
case 'one file many tracks':
return """REM GENRE Hard Rock
REM DATE 1972
REM DISCID 12345678
REM COMMENT ExactAudioCopy v1.0b3
Expand Down Expand Up @@ -57,4 +64,28 @@ def cue_sample_for_durations():
REM REPLAYGAIN_TRACK_PEAK 1.042687
INDEX 00 24:00:00
INDEX 01 24:00:00
"""
case 'two files many tracks':
return """REM GENRE "Synthpop"
REM DATE "2020"
PERFORMER "Various Artists"
TITLE "Album Title"
FILE "01. Side A.flac" WAVE
TRACK 01 AUDIO
INDEX 01 00:00:00
TRACK 02 AUDIO
INDEX 01 04:00:0
TRACK 03 AUDIO
INDEX 01 08:00:00
TRACK 04 AUDIO
INDEX 01 12:00:00
FILE "02. Side B.flac" WAVE
TRACK 05 AUDIO
INDEX 01 00:00:00
TRACK 06 AUDIO
INDEX 01 04:00:00
TRACK 07 AUDIO
INDEX 01 08:00:00
TRACK 08 AUDIO
INDEX 01 12:00:00
"""