grabster/CLAUDE.md
orca fbde195395 Stream torrents from Torznab indexers into the built-in player
Engine
- Bundle rqbit 9.1.0 (scripts/fetch-rqbit.sh, pinned SHA-256 per arch), started on
  first use: 127.0.0.1 + random port, random Basic-auth password passed in its env,
  UPnP off, session/DHT cache/log under the app data dir, downloads in
  ~/Downloads/Grabster/Torrents. Stopped with Grabster like NZBGet.
- torrent_add peeks at the file list, then adds only the playable files (no samples);
  torrent_stats / torrent_remove (Ditch = delete with data).
- engine.rs: spawn_supervised / wait_for_port shared by NZBGet and rqbit.
- http.rs: tiny loopback HTTP client (Content-Length, chunked, streaming bodies).

Playback
- media.rs proxies torrent streams (Source::Remote) so the page never sees rqbit's
  password; suffix ranges become explicit ones; the MKV subtitle fix now runs lazily on
  the first request, so it also works on streams.
- Player items are a finished download or a stream. Streams show "Connecting to
  peers…", then speed / peers / % on disk in the strip. Stop asks Keep or Ditch;
  starting something else over an undecided stream asks first.

Search
- Indexers have a type: Newznab (Usenet) or Torznab (Prowlarr, Jackett). Torznab
  results show seeders; double-click or the Stream button plays them.
- Mock mode: a Torznab indexer with public-domain films, and a simulated rqbit.

Tests: http client, playable-file picking, proxy (auth, ranges, MKV fix) against a
fake rqbit, and an opt-in end-to-end test against the real rqbit with the Creative
Commons Sintel torrent (cargo test --lib -- --ignored real_rqbit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 21:31:34 -05:00

10 KiB
Raw Permalink Blame History

Grabster — agent notes

Grabster is a Usenet downloader for Linux (developed on Nobara / Fedora) whose UI is an homage to the early-2000s P2P clients (WinMX era): grey bevelled Win9x chrome, a row of big tab buttons, dense black list panes with yellow/green/red/cyan column text, Tahoma 11px. It is a front end only: NZBGet does all downloading (NNTP, yEnc, par2, unpack) and Newznab indexers provide search. NZBGet is bundled: Grabster starts its own copy by default ("built-in" mode) and can still talk to an external one ("My own NZBGet"). A built-in player plays finished downloads, and rqbit (also bundled) streams torrents from Torznab indexers (Prowlarr, Jackett) into that player.

The owner is a senior frontend dev (Vue 3, TypeScript, CSS, graphic-design background). Keep code idiomatic Vue 3 <script setup> + TS, no UI framework, hand-written CSS.

Hard rules

  • Original branding only. Never use the WinMX name, logo, icons or text in the app. Recreate the general look (colours, bevels, layout density), not its assets. Icons are hand-drawn SVGs in src/components/Icon.vue; add new ones there in the same 16×16 pixel style.
  • "Grabster" is a placeholder name; renaming means package.json, index.html, src-tauri/tauri.conf.json (productName, identifier, window title), src-tauri/Cargo.toml, src-tauri/src/main.rs (grabster_lib), and strings in src/state.ts / App.vue.
  • Don't reinvent the download engine. Talk to NZBGet over JSON-RPC.
  • Mock mode must keep working: npm run dev in a plain browser uses services/mock.ts. Any new engine/search capability needs a mock implementation too.

Stack

  • Tauri 2 (thin Rust shell) + Vue 3 + TypeScript + Vite.
  • Tauri plugins: http (CORS-free fetch to NZBGet/indexers), store (settings.json), opener (open folders), dialog (pick .nzb files).
  • Custom Rust commands: read_file_base64 in src-tauri/src/lib.rs; media_list / media_trash in src-tauri/src/media.rs (loopback HTTP server with Range support so <video> can play finished downloads: random port + per-launch token, only serves files it listed; "Ditch" moves to the Trash and only for listed folders strictly inside the download folder); builtin_engine_start / builtin_engine_stop in src-tauri/src/engine.rs (spawns the bundled NZBGet in server mode, random port + password written to its 0600 nzbget.conf, PR_SET_PDEATHSIG, flock against a second instance, SIGTERM on exit). torrent_add / torrent_stats / torrent_remove in src-tauri/src/torrent.rs (starts the bundled rqbit on first use: random port, random Basic-auth password in its env, UPnP off, only a torrent's playable files via only_files). Shared helpers for both engines (spawn_supervised, wait_for_port, terminate) live in engine.rs; src-tauri/src/http.rs is a tiny loopback HTTP client for rqbit.
  • Torrent streams are proxied through media.rs (Source::Remote): the page never sees rqbit's password, suffix ranges become explicit ones (rqbit doesn't parse bytes=-N), and the MKV subtitle fix runs lazily on the first request (it reads the file head through rqbit).
  • Bundled rqbit: scripts/fetch-rqbit.sh (pinned version + SHA-256 per arch) into src-tauri/resources/rqbit/ (git-ignored). Downloads go to ~/Downloads/Grabster/Torrents; session + DHT cache (XDG_CACHE_HOME) + rqbit.log in ~/.local/share/com.orca.grabster/rqbit/. rqbit API notes: POST /torrents?list_only=true (body = magnet/URL) to peek at files, ?overwrite=true&only_files=1,4, GET /torrents/{hash}/stats/v1 ("mbps" is MiB/s), POST /torrents/{hash}/delete|forget, stream at /torrents/{hash}/stream/{file}.
  • Bundled NZBGet: scripts/fetch-nzbget.sh (pinned version + SHA-256) unpacks into src-tauri/resources/nzbget/ (git-ignored), shipped via bundle.resources in tauri.conf.json. Runtime data: ~/.local/share/com.orca.grabster/nzbget/. ${AppDir} in NZBGet's config is the read-only resources folder — keep writable paths under ${MainDir}.
  • __NV_DISABLE_EXPLICIT_SYNC=1 is set in run() when the NVIDIA driver is loaded: WebKitGTK on Wayland + NVIDIA EGL dies with "Error 71 (Protocol error)" otherwise. Don't go back to WEBKIT_DISABLE_DMABUF_RENDERER=1: it also avoids the crash but forces CPU compositing (~2x CPU during video in a large window, visible stutter).
  • Video: WebKitGTK 2.54 never loads an MKV with subtitle tracks (stuck at readyState 0), so media.rs serves subtitle TrackType bytes as "metadata". tiny_http needs with_chunked_threshold(usize::MAX) or it drops Content-Length and seeking breaks.
  • Permissions live in src-tauri/capabilities/default.json — add a permission there when using a new plugin API (e.g. core:window:allow-set-title is already there).

Layout

src/
  main.ts, App.vue          shell: banner row, tab buttons, status bar, fake title bar in browser mode
  state.ts                  global reactive `app`, polling loop, search sessions, download()
  player.ts                 built-in player: one media element (or a mock timer), playlist, Keep/Ditch prompt;
                            `player.item` is a Playing (a finished `download` or a torrent `stream`)
  styles.css                bevel classes (.raised/.sunken/.btn/.field), .listview, colour classes
  services/
    types.ts                Settings, SearchHit/SearchRow, QueueItem, HistoryItem, EngineStatus
    backend.ts              Engine, SearchProvider, MediaLibrary, TorrentEngine interfaces
    nzbget.ts               NZBGet JSON-RPC (status, listgroups, history, append, editqueue, rate, config,
                            loadconfig/saveconfig/reload for news servers, testserver)
    newznab.ts              Newznab/Torznab XML search + caps test (DOMParser, newznab:attr; torznab
                            seeders/peers/magneturl → SearchHit.torrent). Indexer.kind picks which.
    media.ts                MediaLibrary (list playable files / trash a download) via Tauri commands
    torrent.ts              TorrentEngine (add / stats / remove) via Tauri commands
    mock.ts                 simulated engine + media + catalog (invented artists, Linux ISOs, public-domain films)
    settings.ts             load/save via tauri store or localStorage
    platform.ts             isTauri, appFetch, openFolder, setWindowTitle, pickNzbFiles
    format.ts               bytesGrouped ("350 758 444"), mb, rate, age, duration, catLabel
  components/
    ListView.vue            generic sortable black list (columns config + #cell-<key> slots)
    SettingsDialog.vue      modal: tree on left, pages on right, Close / Reset Defaults
    NowPlaying.vue          player strip above the status bar (transport, LCD title/time, seek, volume)
    PlayerStage.vue         the <video>: fills the tab area, mini corner window, or fullscreen; mock test card
    KeepDitchDialog.vue     "Finished playing — Keep or Ditch?"
    Slider.vue              Win9x trackbar
    Icon.vue                original pixel icons
  views/                    one per tab: Networks, Library, Chat, Search, Hotlist, Transfers, Bandwidth
src-tauri/                  Rust shell, tauri.conf.json, capabilities, icons

Conventions

  • Colour meaning in lists: .y yellow = ages/categories/times, .g green = good/speed/grabs, .rd red = failed/passworded, .cy cyan = indexer names/post-processing, .gr grey = secondary.
  • Search legend: yellow row text = already in history, cyan = in queue, blue row bg = downloading.
  • Every view puts its left status-bar text in app.viewStatus[tab] (App.vue renders the one bar).
  • Buttons are .btn; pressed/toggled state is .down; active tab is .tab.active.
  • NZBGet editqueue uses the v18+ signature (Command, Param, IDs).
  • Editing NZBGet config: loadconfig (file contents, not runtime -o overrides) → change → saveconfig (replaces the WHOLE file) → reload. Never save from config.
  • KeepAlive wraps the views — guard anything that measures DOM (see the zero-width check in BandwidthView's canvas draw, which once caused an infinite loop).

Commands

npm install
npm run dev            # browser, mock data, http://localhost:1420
npm run tauri dev      # real app with the bundled NZBGet (needs Rust/WebKit deps, see README)
npm run fetch:nzbget   # (re)download the bundled NZBGet; tauri dev/build run it automatically
npm run build          # vue-tsc type-check + vite build
npm run build:preview  # single-file mock-mode HTML in dist-preview/
npm run tauri build    # .rpm + AppImage in src-tauri/target/release/bundle

Always run npx vue-tsc --noEmit after changes.

Status

  • v0.1 front end type-checks, builds, and was visually checked in headless Chromium (mock mode).
  • Rust side builds and runs on Nobara (Nov 2026); .rpm bundles NZBGet 26.3 (~12 MB).
  • Built-in engine tested: start, news server save/reload round trip, testserver, shutdown on crash.
  • Not yet tested with a real Usenet provider or real indexers.
  • Torrent streaming: end-to-end test against the real bundled rqbit passes (cargo test --lib -- --ignored real_rqbit: adds the Creative Commons Sintel magnet, seeks through the proxy). Mock flow checked in headless Chromium. Not yet tried in the real app UI.
  • Player: playback goes through WebKitGTK → GStreamer, so codecs need gstreamer1-plugin-libav (installed on the owner's Nobara). Mock-mode flow checked in headless Chromium; not yet tried in the real app.

Roadmap / ideas

  1. Test with the owner's Usenet provider + indexers; check the AppImage bundle.
  2. Visual polish pass against reference screenshots (spacing, fonts, colours).
  3. Right-click context menus; resizable/remembered column widths.
  4. Torrents, next steps: list kept torrents in Library/Transfers (rqbit GET /torrents), stop seeding after a ratio, optional bind-to-VPN-interface setting (rqbit --bind-device).
  5. Hotlist auto-grab: poll saved searches / RSS and send new matches to NZBGet.
  6. Chat tab as an IRC client.
  7. Per-indexer API hit counters; indexer priority.
  8. Maybe someday: native Rust NNTP engine to drop the NZBGet dependency.