Skip to content

feat: primary-clip variant detection, commentary specials, disc8/disc9 fixtures#19

Merged
yxbh merged 4 commits intomainfrom
test/disc8-fixture
Feb 27, 2026
Merged

feat: primary-clip variant detection, commentary specials, disc8/disc9 fixtures#19
yxbh merged 4 commits intomainfrom
test/disc8-fixture

Conversation

@yxbh
Copy link
Owner

@yxbh yxbh commented Feb 27, 2026

Summary

Add primary-clip variant detection, commentary special detection via IG menu analysis, and ICS fallback loading for test fixtures. Add disc8 and disc9 fixtures with integration tests.

Background

Some Blu-ray discs include multiple playlists for the same content with different audio tracks or short ending clips. These were not caught by exact signature dedup because their full segment keys differ. This caused disc9 (single-movie disc) to be incorrectly analyzed as 2 episodes + 0 specials instead of 1 episode + 1 special.

Additionally, disc menus can list audio commentary tracks as special features — these are IG menu buttons that JumpTitle to episode playlists (not separate playlists). Without IG analysis, these were invisible to the special feature detector.

Changes

Primary-clip variant detection

  • bdpl/analyze/signatures.py: Add find_primary_clip_variants() — groups playlists sharing the same dominant first clip (>85% of total duration) with similar timing
  • bdpl/analyze/__init__.py: Integrate variant detection into dedup pipeline (step 1b); add _maybe_collapse_variant_episodes() to prevent chapter splitting when variant dedup reduces episode count to one

Commentary special detection (new)

  • bdpl/analyze/__init__.py: _detect_special_features() now identifies IG menu buttons that JumpTitle to episode playlists from non-chapter-selection pages as commentary specials
  • Chapter-selection pages (all buttons target same title with different reg2 chapter indices) are excluded from commentary detection to avoid false positives
  • Stream-variant playlists are skipped using the existing variant_mpls set

ICS fallback loading (new)

  • bdpl/analyze/__init__.py: _parse_ig_hints() now falls back to loading ics_menu.bin from the BDMV path when no STREAM/*.m2ts files are available — enables IG-based analysis in test fixtures without bundling media streams

Disc8 fixture

  • tests/fixtures/disc8/: 7 MPLS, 11 CLPI, index.bdmv, MovieObject.bdmv, META/DL/bdmt_eng.xml, ics_menu.bin
  • tests/test_disc8_scan.py: 2 episodes (4 scenes each), 3 specials (2 commentaries + 1 lyrics ending)

Disc9 fixture

  • tests/fixtures/disc9/: 4 MPLS, 9 CLPI, index.bdmv, MovieObject.bdmv, META/DL/bdmt_eng.xml
  • tests/test_disc9_scan.py: 1 episode (movie ~90min), 1 special (alt-audio variant)

Shared changes

  • tests/conftest.py: Add disc8/disc9 path and analysis fixtures
  • tests/test_disc_matrix.py: Add disc8/disc9 to all 6 matrix parametrizations

Testing

  • ruff check . — all checks passed
  • ruff format . — all files formatted
  • pytest -q — 186 tests passed (up from 154)
  • All existing disc1–disc7 test expectations unchanged

Additional Notes

  • Disc8 specials: 3 (2 commentaries referencing episode playlists + 1 lyrics credit ending on 00005.mpls; 00006.mpls is a stream variant excluded by dedup)
  • Disc9: variant detection correctly groups 00002.mpls + 00003.mpls as duplicates; 00002 becomes the representative episode, 00003 becomes special
  • Disc2 ICS fallback loads 27 IG hints but produces no false commentary detections (all JumpTitle targets are on chapter-selection pages)
  • All fixture titles are generic per copyright guidelines

yxbh and others added 2 commits February 27, 2026 21:02
Add disc8 fixture from a two-episode OVA disc (vol 3 of box set):
- 2 episodes: ep1 (54min, 4 scenes), ep2 (60min, 4 scenes)
- 2 specials: stream variants of same clip (different audio tracks)
- Play-all playlist (00002.mpls) with both episodes + outro
- Generic disc title via META/DL/bdmt_eng.xml

Tests: episode count, ordering, scene counts, durations,
special count/durations, disc title, play-all classification.
Matrix entries for episodes, specials, segments, chapter-split, title.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add disc9 fixture from a single-movie disc (vol 4 of box set):
- 2 playlists sharing main clip 00006 (~90min) with different
  secondary clips and stream layouts (stream variants)
- Analysis finds 2 episodes, 0 specials (user expects 1 ep + 1 special)
- Known limitation: stream-variant playlists with different secondary
  clips are not detected as duplicates
- Generic disc title via META/DL/bdmt_eng.xml

Tests: episode count, ordering, shared clip, durations, scene counts,
no specials, disc title. Matrix entries for all 6 parametrizations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yxbh yxbh changed the title test: add disc8 fixture and integration tests test: add disc8 and disc9 fixtures with integration tests Feb 27, 2026
…sode

Add find_primary_clip_variants() to signatures.py that groups playlists
sharing the same dominant first clip (>85% of total duration) with
similar timing, even when secondary clips differ (e.g. alt-audio or
commentary versions with different outros).

Add _maybe_collapse_variant_episodes() to prevent chapter splitting from
incorrectly decomposing a single movie into multiple episodes when
variant dedup reduces the episode playlist count to one.

This fixes disc9 analysis: was 2 episodes + 0 specials, now correctly
produces 1 episode + 1 special (alt-audio variant).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yxbh yxbh changed the title test: add disc8 and disc9 fixtures with integration tests fix: primary-clip variant detection + disc8/disc9 fixtures Feb 27, 2026
Add commentary special detection: IG menu buttons that JumpTitle to
episode playlists from non-chapter-selection pages are recognized as
audio commentary features. A chapter-selection page is identified by
having all JumpTitle buttons targeting the same title number.

Add ICS file fallback to _parse_ig_hints so test fixtures without
STREAM/*.m2ts can still provide IG menu data via ics_menu.bin.

Skip stream-variant playlists in special feature detection using the
existing variant_mpls set from the dedup pipeline.

Disc8 now correctly detects 3 specials (2 commentaries + 1 lyrics
credit ending) matching the disc menu. Disc2 ICS fallback loads
27 hints but produces no false commentary detections.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@yxbh yxbh changed the title fix: primary-clip variant detection + disc8/disc9 fixtures feat: primary-clip variant detection, commentary specials, disc8/disc9 fixtures Feb 27, 2026
@yxbh yxbh merged commit 55b6ac5 into main Feb 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant