grabster/scripts/fetch-rqbit.sh
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

45 lines
1.8 KiB
Bash
Executable file

#!/usr/bin/env bash
# Downloads the official static rqbit build (the torrent engine behind "Stream") into
# src-tauri/resources/rqbit/. Runs automatically before `npm run tauri dev` /
# `npm run tauri build`; does nothing if already present.
#
# To upgrade rqbit: change VERSION and the SHA256s (from the release's asset digests:
# gh api repos/ikatson/rqbit/releases/latest --jq '.assets[] | select(.name|startswith("rqbit-linux-")) | "\(.name) \(.digest)"'
set -euo pipefail
VERSION="9.1.0"
SHA256_X86_64="921061a82ee6a6b26754c6367886b5b6b4ce5916d3edd5db79c6cd5f2c23499f"
SHA256_AARCH64="5247a363df062f429e53661b7242373bf70603e93efc4d0b459017e6fd209def"
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OUT="$ROOT/src-tauri/resources/rqbit"
CACHE="$ROOT/src-tauri/target/rqbit-download"
if [[ "$(cat "$OUT/VERSION" 2>/dev/null)" == "$VERSION" ]]; then
exit 0
fi
case "$(uname -m)" in
x86_64) ASSET=rqbit-linux-amd64; SHA256=$SHA256_X86_64 ;;
aarch64 | arm64) ASSET=rqbit-linux-arm64; SHA256=$SHA256_AARCH64 ;;
*) echo "fetch-rqbit: unsupported CPU $(uname -m)" >&2; exit 1 ;;
esac
mkdir -p "$CACHE"
BIN="$CACHE/$ASSET-$VERSION"
if ! echo "$SHA256 $BIN" | sha256sum -c --status 2>/dev/null; then
echo "fetch-rqbit: downloading rqbit $VERSION…"
curl -fL --proto '=https' -o "$BIN.part" "https://github.com/ikatson/rqbit/releases/download/v${VERSION}/${ASSET}"
mv "$BIN.part" "$BIN"
fi
echo "$SHA256 $BIN" | sha256sum -c --quiet
rm -rf "$OUT"
mkdir -p "$OUT"
cp "$BIN" "$OUT/rqbit"
chmod 755 "$OUT/rqbit"
# rqbit is Apache-2.0; ship the notice with it.
curl -fsSL --proto '=https' -o "$OUT/LICENSE" "https://raw.githubusercontent.com/ikatson/rqbit/v${VERSION}/LICENSE" \
|| echo "rqbit $VERSION, Apache-2.0: https://github.com/ikatson/rqbit" > "$OUT/LICENSE"
echo "$VERSION" > "$OUT/VERSION"
echo "fetch-rqbit: rqbit $VERSION ready in src-tauri/resources/rqbit"