Risuko
Node.js API

Options

Read and modify engine and per-task options at runtime.

Per-Task Options

getOption

Get the options for a specific download task.

function getOption(gid: string): Promise<Record<string, unknown>>;
const options = await getOption(gid);
console.log(options.dir);     // Download directory
console.log(options.split);   // Number of connections

changeOption

Change options for a running task. Only some options can be changed after a download starts.

function changeOption(
  gid: string,
  options: Record<string, unknown>
): Promise<void>;
// Limit download speed to 1 MB/s
await changeOption(gid, { "max-download-limit": "1048576" });

Changeable Options

changeOption merges the provided keys into the task's option map, so any key can be stored. Only a subset is consumed live by the engine:

KeyEffect on a running task
max-download-limitUpdates the per-task download speed limit on the next tick (bytes/sec, "0" for unlimited)
max-upload-limitUpdates the per-torrent upload speed limit (BitTorrent)
seed-timeSetting to "0" while a torrent is seeding (and seed-ratio is also 0 or absent) stops seeding immediately and emits risuko.onDownloadComplete
seed-ratioSame stop-on-zero behaviour as seed-time; otherwise re-evaluated by the seeding loop

Other options are stored on the task and used the next time a relevant action runs (for example, dir/out when the task is restarted).

Global Options

getGlobalOption

Get the current global engine options.

function getGlobalOption(): Promise<Record<string, unknown>>;
const global = await getGlobalOption();
console.log(global["max-concurrent-downloads"]);
console.log(global["max-overall-download-limit"]);

changeGlobalOption

Change global engine options. These affect new downloads and some aspects of running downloads.

function changeGlobalOption(
  options: Record<string, unknown>
): Promise<void>;
// Limit to 3 concurrent downloads
await changeGlobalOption({ "max-concurrent-downloads": "3" });

// Set global speed limit to 10 MB/s
await changeGlobalOption({ "max-overall-download-limit": "10485760" });

Global Option Reference

Defaults come from system_defaults() in src-tauri/risuko-engine/src/config/defaults.rs and are stored as JSON numbers/strings; changeGlobalOption accepts either form.

KeyDefaultDescription
dirOS Downloads dirDefault download directory
max-concurrent-downloads5Maximum number of parallel downloads
max-overall-download-limit0Global download speed limit (bytes/s, 0 = unlimited; updates the SpeedLimiter immediately)
max-overall-upload-limit0Global upload speed limit (bytes/s)
split16Default number of HTTP connections for new downloads
user-agentChrome UA stringDefault user agent string
all-proxy""Default proxy URL
rpc-listen-port16800RPC server port (read at startEngine only)

On this page