github mesamirh/MovieBox-Tui v0.1.25

4 hours ago

Fixed

  • Search Navigation & Pagination Engine:
    • Gated background search pagination in src/tui/app/navigation.rs so arrow navigation on result sets smaller than the visible viewport never triggers background page fetches.
    • Added search_exhausted tracking in src/tui/state.rs and src/tui/app/requests.rs, stopping pagination crawls when provider search returns fewer than 15 items or zero query-matching results.
    • Preserved stable card slot positions during search pagination in src/tui/app/requests.rs by appending subsequent page items to the list rather than re-sorting the entire array out from under the cursor.
    • Removed redundant "Provider: {name}" status message override from the search bar on provider switch in src/tui/app/navigation.rs, preserving the clean search placeholder while the active provider pill displays on the right.
  • Media Playback & Buffering Engine:
    • Prioritized native desktop media players (mpv, VLC) over Android intent openers in src/player.rs when an active X11/Wayland display server ($DISPLAY, $WAYLAND_DISPLAY) is detected, preventing Ubuntu Xfce (udroid/PRoot) and Termux:X11 desktop sessions from dispatching playback to external Android app choosers.
    • Routed DASH .mpd streams through the local StreamRelay proxy (src/proxy.rs, src/tui/app/playback.rs) across all media players (mpv, IINA, VLC, AndroidIntent), caching rewritten .mpd manifests in RAM, warm-prefetching initialization and opening segments on sidecar startup, fetching .m4s segments via concurrent 95 KB HTTP Range sub-requests (0.286s per segment vs 3.120s), and prefetching both the next 3 video segments (N+1..N+3) and synchronized audio segments (chunk-stream3-N..N+1).
    • Tuned mpv and IINA playback flags (--hwdec=auto-safe, --stream-buffer-size=4M, --cache-secs=120, --cache-pause-wait=3, --cache-pause-initial=no, and --ytdl=no on non-DASH direct streams) in src/player.rs, reducing 1080p cold-seek latency at 01:00:00 from 11.96s to 3.87s and boosting read-ahead buffer fill rate from 1 MB (9.3s) to 7 MB (53s).
    • Replaced aggressive VLC buffering flags (--network-caching=10000, --adaptive-logic=nearoptimal) with --network-caching=3000, --file-caching=3000, --http-reconnect, and --adaptive-logic=predictive in src/player.rs to stop demuxer stream restarts and reconnect cleanly on dropped HTTP streams.
    • Enforced max_height resolution limits in the loopback stream proxy manifest rewriter (src/proxy.rs, src/main.rs, src/tui/app/playback.rs), pruning representations exceeding the chosen ceiling so Android players and VLC respect 480p and 720p selections.
    • Parsed signed expiration timestamps (:t=) from MovieBox Edge-Cache-Cookie headers in src/cache.rs alongside CloudFront policies, automatically invalidating stale stream cache entries within 60 seconds of expiration to prevent HTTP 403 playback crashes.
    • Persisted selected stream filenames (stream_filename) in watch history (src/history.rs, src/player/tracker.rs, src/tui/app/playback.rs) and auto-focused matching stream rows on load (src/tui/app/requests.rs, src/tui/app/system.rs), restoring the user's previously chosen quality mirror when resuming multi-stream releases.
    • Enabled TCP nodelay (stream.set_nodelay(true)) and per-chunk immediate flushes on the local StreamRelay proxy in src/proxy.rs, eliminating 100–300ms time-to-first-frame buffering delays on loopback sockets.
    • Implemented negative caching (Option<Option<String>>) for media player detection (MPV_CACHED, VLC_CACHED, IINA_CACHED) in src/player.rs, eliminating redundant filesystem scans and registry lookups when players are absent.
    • Throttled Lua tracker periodic disk sync in src/player/tracker.rs when playback is paused or positional change is sub-second, cutting SSD writes by up to 90% during playback pauses.
    • Removed duplicate redundant history.save() calls in src/tui/app/playback.rs upon marking items watched.
    • Defined local now = os.time() in src/player/tracker.rs before formatting playback state JSON in moviebox_tracker.lua and scoped initial PendingPlaybackState seed writes in src/tui/app/playback.rs strictly to PlayerKind::Mpv, preventing VLC, IINA, and AndroidIntent watch progress from resetting to 0 on player exit.
    • Detached spawned media players and the StreamRelay sidecar into independent OS sessions via configure_detached_process (libc::setsid() + SIGHUP ignore on Unix, DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP on Windows) in src/player.rs, src/proxy.rs, and src/tui/app/playback.rs, redirected player stderr to temporary log files instead of parent pipes to prevent SIGPIPE crashes when the terminal closes, and reaped the sidecar immediately when desktop players exit while the TUI is open.
  • Download Engine & Subprocess Diagnostics:
    • Added preflight verification for ffmpeg alongside yt-dlp in src/tui/app/download.rs, failing fast with installation guidance when media muxing tools are missing.
    • Captured child process stderr lines during DASH transfers to surface concrete yt-dlp error diagnostics instead of bare exit codes.
    • Accelerated MovieBox DASH stream downloads from ~0.92 MiB/s to ~10.29 MiB/s by passing --http-chunk-size 95K and --concurrent-fragments 8 to yt-dlp with resilient retry policies (--fragment-retries 10, --retries 5, --socket-timeout 30) in src/tui/app/download.rs, resetting Alibaba Cloud Tengine's per-request limit_rate_after 96k rate-limiter across persistent Keep-Alive sockets.
    • Refactored the direct HTTP multi-segment downloader in src/download.rs to pre-allocate the .part file and write segments in-place via positional SeekFrom::Start offsets (scaling concurrency to 4–12 workers down to 16 MB files), eliminating temporary .part.N files and the post-download .assembling full-file disk copy.
  • TUI Rendering & Event Loop Performance:
    • Expanded terminal standard output BufWriter capacity from 64 KB to 256 KB in src/main.rs, enabling atomic frame flushes and eliminating visual tearing during graphical Sixel and Kitty poster transfers.
    • Replaced allocating to_string() hash set checks in src/favorites.rs with zero-allocation borrowed string comparisons in is_favorite, eliminating 400+ heap allocations per second during search grid rendering.
    • Eliminated redundant 100ms idle tick redraws on static home screens in src/tui/app/system.rs, dropping idle CPU consumption to zero.
    • Replaced per-card Layout::split invocations in src/tui/screens/home.rs with direct row arithmetic calculations, avoiding repeated layout solver overhead across search result slots.
    • Rendered stream media tags (HDR, ATMOS, 5.1, HEVC, AV1, WEB-DL) in src/tui/screens/details.rs using styled surface pill spans and unified background modal dimming to theme.muted across render_media_tag_spans, resolution_badge_spans (src/tui/widgets/badge.rs), render_poster_placeholder (src/tui/widgets/poster.rs), Details headers (src/tui/screens/details.rs), and Home search result bars, cards, ratings, and history progress rows (src/tui/screens/home.rs).
    • Replaced linear index iteration with exact O(1) HashSet lookups in FavoritesManager::is_favorite (src/favorites.rs).
    • Guarded PopKeyboardEnhancementFlags in restore_terminal (src/main.rs) against Termux environments (!is_termux_environment()), preventing stray ANSI escape sequences from leaking into the Android Termux shell on exit.
    • Routed Warning: and non-Home Action::SetStatus messages through toast notifications in src/tui/app/system.rs, src/tui/app/playback.rs, and src/tui/app/requests.rs, ensuring subtitle fallback notices, missing iina-cli warnings, and addon installation statuses remain visible on the Details screen and modal overlays.
    • Unified notification card geometry and line-wrapping calculations in compute_notification_cards (src/tui/overlay.rs), eliminating duplicate layout passes between frame rendering and mouse click hit-testing.
  • Provider Scraping & Concurrency Engine:
    • Replaced chunked mirror resolution barriers in 4KHDHub (src/providers/fourkhdhub/client.rs, src/providers/fourkhdhub/hubcloud.rs) with HTTP 206 Partial Content seekability verification (preflight_with_seekable) and score-prioritized early termination (is_seekable && score <= 1), ensuring byte-range-seekable 10Gbps/R2/FSL mirrors are selected over unseekable HTTP 200 mirrors or quota-exhausted workers.dev links.
    • Centralized disk-cached caption lookup and storage in MovieBoxService::get_ext_captions (src/service.rs) and parallelized primary and sibling dub caption fetches via tokio::join!, eliminating duplicate cache wrappers in src/tui/app/playback.rs and src/tui/app/requests.rs.
    • Bound individual Stremio addon stream fetches in src/providers/addons/aggregator.rs with a 5-second timeout, preventing unresponsive third-party addons from blocking stream aggregation.
    • Capped initial search poster scraping in DhakaFlix (src/providers/bdix/dhakaflix/client.rs) to the first 20 items, eliminating dozens of blocking HTTP POST requests on large catalog searches.
    • Centralized MediaDetails::sibling_ids, human-readable file size parsing (parse_size_bytes), DASH URL detection (is_dash_url), yt-dlp format selectors (ytdlp_format_selector), download target path resolution (resolve_media_target), and cached poster fetching (MovieBoxService::fetch_and_decode_cached_poster) in their owning domain modules (src/providers/models.rs, src/player.rs, src/download.rs, src/service.rs), and removed src/tui/app/network.rs.
    • Streamed poster HTTP responses via bounded chunk accumulation (5 MiB cap) in MovieBoxService::fetch_poster_bytes (src/service.rs) and added FallbackResolver DNS + Range: bytes=0-0 bounds to probe_url (src/net.rs).
  • Storage & Disk Cache Engine:
    • Optimized typed cache serialization in src/cache.rs using direct in-place encoding (rmp_serde::encode::write) into pre-seeded magic header buffers, eliminating intermediate vector allocations and duplicate memory copies.
    • Pre-allocated file buffer capacity from file metadata in get_typed_cache in src/cache.rs, eliminating repetitive vector reallocations during cache reads.
    • Offloaded atomic_write_file_async in src/cache.rs to tokio::task::spawn_blocking, switched src/logging.rs to WriteMode::BufferAndFlush with a LazyLock cached home directory path, centralized corrupt JSON file rotation (rotate_corrupt_file) in src/config.rs, and enabled cross-platform stale update artifact cleanup in src/updater/apply.rs.
    • Isolated all unit and integration test runs into a per-process temporary sandbox (TEST_SANDBOX_DIR in src/config.rs) and guarded external browser launches (open_external_url in src/net.rs), preventing tests from modifying real user configuration, watch history, favorites, or disk cache files.
    • Added unit and mock-server test coverage for 4KHDHub HTTP 206 seekable mirror prioritization, CircleFTP catalog mapping, DhakaFlix stream extraction, Addons concurrent stream aggregation and torrent filtering, TV UTF-8 BOM / HLS M3U parsing, IINA command construction, StreamRelay DASH sidecar warmup, non-mpv watch progress retention, and Action::SetStatus warning/modal toast routing.

Changed

  • TUI & Ergonomics:
    • Remapped q / Q on Screen::Details in src/tui/app/keyboard.rs from application exit to Action::GoBack, preserving active search results and returning to the home screen without unexpected process termination.
    • Standardized modal and popup dismissal across Settings, Providers, Browse Presets, Sources, Themes, Addons, and TV Config overlays to dismiss on both Esc and q.
    • Reordered episode list label formatting in src/tui/screens/details.rs to compute prefix and progress badge widths before truncating episode titles, strictly preventing list item text overflow and jagged multi-line wrapping.
    • Replaced ambiguous " ... [i]" plot synopsis truncation with an explicit " ... [i: More]" indicator in src/tui/screens/details.rs.
    • Optimized stream table column constraints for ultra-compact terminals (<65 columns) in src/tui/screens/details.rs, compacting SIZE to 7 characters and reclaiming columns for release title readability on mobile viewports.
    • Rendered cached IMDb rating badges across all visible search cards in src/tui/screens/home.rs by peeking preview_cache, enabling at-a-glance quality comparison across the grid without manual card-by-card selection.
    • Collapsed empty [No Art] poster placeholder columns when image_supported is false in src/tui/screens/home.rs, expanding search card text and metadata across the full available column width on non-graphical terminals.
  • Documentation & Cross-Platform Terminal Compatibility:
    • Documented native Windows Terminal Sixel image support requirements (v1.22+ via Microsoft Store) in docs/cross-platform.md and README.md, clarifying that no third-party terminal or configuration is required on Windows.

Don't miss a new MovieBox-Tui release

NewReleases is sending notifications on new releases.