fix: don't crash on a file with no subtitle tracks #15
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/no-subtitle-tracks-crash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
tag_episode.pydied withIndexError: list index out of rangeon any filecarrying no subtitle tracks, before printing even the audio plan it had already
built. An empty list has no middle element:
max(len(p[3]) for p in plan)raises the same way on a file with no audioeither.
This is not an edge case. A Jellyfin audit on 2026-10-22 found 3,201 of 8,052
library files carry no subtitle stream, so it is the normal shape of a streaming
pull.
Changes
Two guards, no behaviour change for files that do have subtitles:
median = (counts[len(counts) // 2] if counts else 0) or 1— the existingor 1already handled a zero median, so the fallback path was there already.w = max((len(p[3]) for p in plan), default=0)Verification
ast.parseand the--helpgate pass acrosslib/*.py. Three real-media runsagainst clips cut from
~/Movies/Rips:IndexError1 audio, 0 subtitle tracksIndexError0 audio, 0 subtitle tracks--applyalso exercised end-to-end on the zero-subtitle file: exit 0, containertitle written, audio track named.
🤖 Generated with Claude Code