1.0.1 • Published 4 years ago

kaven-aria2 v1.0.1

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

Kaven-Aria2

js wrapper for aria2.

Usage

import {
    SocketExecutor, Aria2, Aria2Builder, Aria2Methods, Aria2Notifications
} from "kaven-aria2";

// comment out the following line if used in browser
import WebSocket from "ws"; // https://github.com/websockets/ws

const aria2rpc = "ws://localhost:6800/jsonrpc";
const executor = new SocketExecutor(aria2rpc, WebSocket);

const aria2 = new Aria2(executor);

// addUri
await aria2.addUri(url, { dir: "path/to/save" });

// multicall
await aria2.multicall(new Aria2Builder(Aria2Methods.getGlobalStat), ...gids.map(p => new Aria2Builder(Aria2Methods.tellStatus).SetParams(p)));

// Notifications
executor.Notification.on((data, _) => {
    if (data.method === Aria2Notifications.onDownloadStart) {
        // ...
    }
});