A prioritized list of improvements, fixes, and enhancements for the jw-scripts project.
- Fix overly permissive API health check in
internal/books/client.go— returns true for 2xx–4xx status codes (including client errors); should only accept 2xx - Use
http.StatusOKinstead of hardcoded200ininternal/books/client.gofor consistency with the rest of the codebase - Handle ignored error from
listVideos()ininternal/player/player.go— error is silently discarded
- Implement offline import for
jwb-music(cmd/jwb-music/main.go) andjwb-index(cmd/jwb-index/main.go) - Investigate books/publications download support — the books framework works with the real JW.org Publication Media API; actual downloads depend on API availability per publication
- Parameterize
latestJWBYearininternal/api/client.go— now computed astime.Now().Year() - jwbYearBase(no yearly manual update needed) - Update default player from
omxplayer(deprecated/removed from most distros) tompv
- Add response body size limit when reading API responses in
internal/books/client.go(io.ReadAllwith no size cap) - Return errors from symlink creation in
internal/output/writer.goinstead of only logging them - Handle
strconv.Atoierrors when parsing resolution ininternal/api/client.goinstead of silently ignoring them - Guard unchecked type assertions (e.g.,
item.(*api.Media)) to prevent potential panics — already uses comma-ok pattern everywhere
- Extract duplicated
contains()helper (defined in bothinternal/api/client.goandinternal/player/player.go) intointernal/util - Unify error handling patterns across the codebase — symlink errors now returned, strconv errors handled, consistent
fmt.Errorfwith%wwrapping - Add a comment or constant for magic numbers:
qualityMatchBonus(200) andsubtitleMatchBonus(100) ininternal/api/client.go
- Add tests for
internal/player— 16 test functions covering all exported and key internal functions - Add integration tests or CLI smoke tests for
cmd/jwb-index,cmd/jwb-music,cmd/jwb-books, andcmd/jwb-offline - Add benchmark tests for the downloader and API client to track performance
- Add a
CHANGELOG.mdto track version history and release notes - Add a troubleshooting section to
README.mdcovering common errors and solutions - Document complex flag combinations and add example outputs to
README.md - Clarify that
jwb-booksis a framework/prototype in its documentation
- Move analysis/debug tools (
cmd/api-analysis,cmd/category-analysis,cmd/character-analysis,cmd/comprehensive-analysis,cmd/media-analysis,cmd/subtitle-diagnostic,cmd/subtitle-count-test) into acmd/debug/orcmd/internal/subdirectory, or exclude them from release builds - Consider adding config file support (e.g., YAML/TOML) alongside CLI flags for persistent settings
- Enable additional golangci-lint checks:
exhaustive,nilnil,bodyclose - Add
nolintlintto verify that#nosec///nolintcomments are still valid