BitTorrent Downloads
Guide to downloading torrents with Risuko.
Risuko includes a full BitTorrent client powered by risuko-bt, an in-tree BitTorrent v1 engine.
Magnet Links
CLI
risuko download "magnet:?xt=urn:btih:abc123def456..."Node.js
import { addMagnet } from "@risuko/risuko-js";
const gid = await addMagnet("magnet:?xt=urn:btih:abc123def456...", {
dir: "/downloads",
});.torrent Files
CLI
risuko download ./ubuntu-24.04.torrent -d ~/DownloadsNode.js
import { readFile } from "node:fs/promises";
import { addTorrent } from "@risuko/risuko-js";
const data = await readFile("./ubuntu-24.04.torrent");
const gid = await addTorrent(data, { dir: "/downloads" });Seeding Control
By default, Risuko does not seed after a torrent completes (keep-seeding is false and seed-time / seed-ratio default to 0). To enable seeding, turn on keep-seeding, or set a finite seed-time / seed-ratio:
Keep Seeding
Seed indefinitely until the task is stopped manually:
await changeGlobalOption({ "keep-seeding": "true" });When keep-seeding is enabled, the seed-time and seed-ratio limits are ignored.
Seed Ratio
Stop seeding when the upload/download ratio reaches a threshold:
risuko download "magnet:?xt=..." --seed-ratio 1.0await addMagnet("magnet:?xt=...", { "seed-ratio": "1.0" });A ratio of 1.0 means upload the same amount as downloaded.
Seed Time
Seed for a number of minutes after download completes:
risuko download "magnet:?xt=..." --seed-time 60await addMagnet("magnet:?xt=...", { "seed-time": "60" });Seeding starts whenever keep-seeding is true, or seed-time > 0, or seed-ratio > 0. If keep-seeding is off, seeding stops when seed-time elapses or seed-ratio is reached, whichever comes first.
Combined Limits
When both seed-time and seed-ratio are set (and keep-seeding is off), seeding stops when either limit is reached first.
Events
BitTorrent downloads emit two completion events:
risuko.onBtDownloadComplete— Download finished, now seedingrisuko.onDownloadComplete— Seeding finished (or limits reached)
onEvent((event, gid) => {
if (event === "risuko.onBtDownloadComplete") {
console.log("Download done, seeding...");
}
if (event === "risuko.onDownloadComplete") {
console.log("Fully complete");
}
});Peer Information
Check connected peers for a torrent download:
risuko peers <gid>const peers = await getPeers(gid);