Projects

BAKA: a terminal torrent search and download client written in Rust

Every so often you find a tool that has exactly the right idea wrapped in exactly the wrong plumbing. That was torlink for me: a torrent finder and downloader that lives in the terminal, no dashboard, no web UI, no daemon to babysit. Search, pick a result, watch it download, all in the same window you were already in. The shape of it was perfect. The delivery was Node, and it launched with npx torlnk.

I am not interested in installing a JavaScript runtime and pulling a package tree from the network every time I want to grab an episode. So I wrote my own: BAKA, short for BitTorrent Acquisition and Keyword Aggregator. Same job, one Rust binary, no runtime, no setup.

What BAKA actually is

BAKA is a terminal torrent search engine and a full BitTorrent client in the same executable. You run baka, you get a TUI built on ratatui with four tabs: Search, Downloads, Seeding and Settings.

Type a query and it fans out across every enabled indexer at once. Paste a magnet link, a bare infohash or the path to a .torrent file into the same box and it stops searching and starts downloading instead, because that is obviously what you meant. Press Enter on an empty box and it browses what the sources are listing right now, taking a share from each category rather than whatever happens to have the fattest swarm.

Downloads run in the background while you keep searching. Interrupted transfers resume on the next launch. Finished downloads seed until you tell them to stop. The whole keymap fits in a table:

KeyAction
/Focus search
EnterRun the search, browse an empty box, or download the selected result
TabSwitch between Search, Downloads, Seeding and Settings
d / DDownload to the default folder, or to a folder you pick
p / xPause or resume, stop and keep what is already on disk
cCopy magnet link
sSettings
? / qHelp, quit

A short, hand-picked source list

There is no indexer proxy to configure and no API key to paste. BAKA ships with a curated list, one scraper module per source:

CategorySources
MoviesYTS, The Pirate Bay, 1337x, BitTorrented
TVEZTV, The Pirate Bay, 1337x, BitTorrented
AnimeNyaa, SubsPlease
GamesFitGirl

Every enabled source is queried in parallel, each on its own timeout, and the results are merged and ranked by seeders and title match. A source that is down gets skipped, not escalated into an error. That rule matters more than it sounds: public indexers go dark constantly, and a search that fails because one of eight sources timed out is a search that fails most of the time.

Two sources behave differently and the Search tab tells you which source every result came from, so you can see it. EZTV publishes a feed of new releases rather than a real search index, so a query filters whatever is currently in that feed. 1337x is blocked or challenged on plenty of networks, so BAKA tries its mirrors in turn and moves on quietly if none of them answer. Game results are executables that can run code on your machine, so those get marked clearly. Video and subtitle results cannot do that, and the interface does not pretend otherwise.

One settings page, one file, zero environment variables

This is the part I care about most, and it is the clearest break from the tool that inspired it. torlink spreads its behaviour across environment variables, one-off keybinds and flags. BAKA has a single Settings page covering downloads, seeding, network, search, server and interface options. Press s, change a row, move on, it saves itself.

Behind that page is exactly one file, config.toml, in the platform config directory: %APPDATA%\baka on Windows, ~/.config/baka on Linux, ~/Library/Application Support/baka on macOS. Edit it by hand if you like. Delete it and everything returns to defaults. Leave half the keys out and the missing values fall back instead of erroring. Command line flags override settings for a single run and never write to disk.

The rule in the repo is that if a persistent knob exists, it appears on that page in the same commit that introduced it. A setting with no home ends up as an environment variable, and environment variables are how a tool becomes something you have to look up.

It also runs without a terminal

The TUI is the product, but the same binary works headless, which is where it stops being a toy and starts being infrastructure:

CommandDoes
baka get <magnet|infohash|file>Download one thing and exit
baka search "<query>"Print results as text
baka watch [dir]Download anything dropped into a directory
baka serveAccept magnets over HTTP
baka filesServe finished downloads over HTTP with range requests

Add --daemon to the last three and they keep running after you close the terminal. The watch folder renames each file it consumes to .taken, or to .failed if there was nothing usable in it. The HTTP intake is a single POST away:

curl -d "magnet:?xt=urn:btih:..." http://127.0.0.1:4241

Both servers bind to 127.0.0.1 by default, which is this machine and nothing else. You can widen that on the Settings page, but think about it first, because the magnet intake downloads whatever it is handed.

Why Rust was the whole point

Downloading runs through librqbit in process, the mature pure-Rust BitTorrent engine with DHT, uTP, resume and seeding. Writing my own engine would have delayed feature parity by months for no user-visible benefit, and librqbit types never leave engine.rs, so swapping it later stays possible.

The release profile turns on LTO, one codegen unit and symbol stripping, because the binary ships through winget and Scoop where download size is the first thing anyone notices. What you install is a portable executable and nothing else. Uninstalling removes the binary and leaves your config.toml and your downloads alone, so reinstalling finds the setup you already had.

There is one honest tradeoff. torlink uses WebTorrent and therefore reaches WebRTC browser peers. librqbit speaks TCP and uTP only, so browser-seeded swarms are out of reach. Normal swarms are unaffected, and it is not planned for 1.0.

The house rule that has nothing to do with torrents

It sits next to the rules that actually govern the code: cargo fmt and clippy -D warnings both clean before anything counts as done, no unwrap outside tests and main, comments explain why and never what, and every scraper is tested against saved fixtures so CI never touches the network. A source silently changing its HTML should break a test, not a user's search.

Install it

cargo binstall b-baka
scoop bucket add baka https://gitlab.ramon.moe/4G0NYY/BAKA
scoop install baka
cargo install b-baka

Scoop covers Windows on x64 and arm64. cargo install works anywhere Rust does, including Linux and macOS. The crates.io name stutters because baka was already taken there, but the command it installs is still baka. Every release also carries plain archives with a SHA256SUMS.txt next to them if you would rather place the binary yourself.

Where it stands

BAKA is pre-alpha, and that word is doing less work than usual here. The interface, the downloads, the settings page and every source listed above all work today, and pushing a version tag builds and publishes a release for both Windows architectures. Phases 0 through 6 are done. Phase 7 is 1.0, and the headline item is baka attach, so a TUI can connect to a session that is already running instead of fighting it for the same state.

One thing worth saying plainly: BAKA is a search tool and a BitTorrent client. It hosts nothing, indexes nothing and mirrors nothing. What you download with it is on you, and copyright law applies the same way it does everywhere else.

The code is MIT licensed and lives here: gitlab.ramon.moe/4G0NYY/BAKA. Credit where it belongs, the idea came from torlink. I just wanted it as a binary.