kaven-aria2
v1.0.1
Published
js wrapper for aria2.
Downloads
4
Readme
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) {
// ...
}
});