7 bugs found and fixed through systematic code audit
Bug #1: Dead code (minor)
_select_episode_range() function was defined but never called. Removed.
Bug #2: Wrong behavior for invalid episode number (minor)
When user requests episode 9999 but anime only has 12 episodes, SNI would silently play from episode 1. Now reports: Episode 9999 not found. This anime has episodes 1-12.
Bug #3: TUI crash — play_episode doesn't exist (major)
EpisodeScreen.on_list_view_selected called self.play_episode(idx) but only play_range is defined. Clicking an episode in the TUI list would crash. Fixed.
Bug #4: TUI freeze during playback (major)
TUI play_range called player.wait() synchronously, which blocks the Textual event loop during playback. The entire UI froze until mpv exited. Fixed by running player.wait() in a thread executor: await loop.run_in_executor(None, player.wait)
Bug #5: TUI auto-next logic broken (minor)
play_range had broken auto-next logic with continue that skipped episodes. Replaced with clean if ep.number >= end_ep: break.
Bug #6: Dub episodes always showed sub count (major)
get_episodes() always used detail.get('sub') even when dub=True. Now accepts dub parameter and uses detail.get('dub') with fallback to sub. Verified: One Piece has 1168 sub episodes but 1155 dub episodes — dub count is now correct.
Bug #7: CRITICAL — Config roundtrip lost CF Worker URL (critical)
Config.save() wrote the CF Worker URL with key cf_worker_url but the model field is allanime_cf_worker_url. Config.load() flattens all sections, so the key mismatch meant the CF Worker URL was silently lost every time config was saved and reloaded. This means sni config --update allanime_cf_worker_url=... would work for the current session but be gone next time. Fixed by using the full model field name as the TOML key. Verified with roundtrip test.
Verified
ruff check sni/→ All checks passedpytest -q→ 6 passed (1.01s)- Live E2E: AniList → AllAnime → 1168 sub + 1155 dub episodes → stream URL resolved
- Config roundtrip: CF Worker URL preserved ✅
- Dub episodes: correct count returned ✅
Install
pip install --upgrade sni-cliFull changelog: v2.1.0...v2.1.1