-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathexample.js
More file actions
25 lines (20 loc) · 859 Bytes
/
example.js
File metadata and controls
25 lines (20 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Aria2 from "./src/Aria2.js"; // or "aria2" if installed with npm
import debug from "./src/debug.js";
(async () => {
const aria2 = new Aria2();
debug(aria2);
// comment to use HTTP
try {
await aria2.open();
} catch (err) {
console.log("Could not connect");
return;
}
aria2.addEventListener("onDownloadStart", ({ params }) => {
console.log("Download start", params);
});
const magnet =
"magnet:?xt=urn:btih:88594AAACBDE40EF3E2510C47374EC0AA396C08E&dn=bbb_sunflower_1080p_30fps_normal.mp4&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80%2fannounce&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce&ws=http%3a%2f%2fdistribution.bbb3d.renderfarming.net%2fvideo%2fmp4%2fbbb_sunflower_1080p_30fps_normal.mp4";
const guid = await aria2.call("addUri", [magnet], { dir: "/tmp" });
console.log("guid", guid);
})();