All Projects → sonnyp → Aria2.js

sonnyp / Aria2.js

Licence: isc
JavaScript library for aria2, "The next generation download utility."

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Aria2.js

Snail
基于Java、JavaFX开发的下载工具,支持下载协议:BT(BitTorrent、磁力链接、种子文件)、HLS(M3U8)、FTP、HTTP。人家才不要你的⭐⭐呢,哼
Stars: ✭ 102 (-78.34%)
Mutual labels:  dht, bittorrent, ftp, magnet
bthello
Python3 DHT 磁力种子爬虫 种子解析 种子搜索 演示地址
Stars: ✭ 43 (-90.87%)
Mutual labels:  bittorrent, dht, magnet
Motrix
A full-featured download manager.
Stars: ✭ 29,357 (+6132.91%)
Mutual labels:  bittorrent, aria2, magnet
torrent-spider
基于DHT的p2p网络资源爬虫
Stars: ✭ 65 (-86.2%)
Mutual labels:  bittorrent, dht, magnet
Aria2 Pro Docker
Aria2 Pro | A perfect Aria2 Docker image | 更好用的 Aria2 Docker 容器镜像
Stars: ✭ 802 (+70.28%)
Mutual labels:  bittorrent, aria2, magnet
Aria2.sh
Aria2 一键安装管理脚本 增强版
Stars: ✭ 1,276 (+170.91%)
Mutual labels:  bittorrent, aria2, magnet
Ut metadata
BitTorrent Extension for Peers to Send Metadata Files (BEP 9)
Stars: ✭ 98 (-79.19%)
Mutual labels:  bittorrent, magnet, browser
Bt
BitTorrent library and client with DHT, magnet links, encryption and more
Stars: ✭ 2,011 (+326.96%)
Mutual labels:  dht, bittorrent, magnet
Torrent Discovery
Discover BitTorrent and WebTorrent peers
Stars: ✭ 177 (-62.42%)
Mutual labels:  dht, bittorrent, browser
MlDHT
MLDHT is an elixir package that provides a mainline DHT implementation according to BEP 05.
Stars: ✭ 88 (-81.32%)
Mutual labels:  bittorrent, dht
peerstohttp
Simple torrent proxy to http stream controlled over REST-like api
Stars: ✭ 30 (-93.63%)
Mutual labels:  dht, magnet
URL-Magnet-Cloud-Uploader-Heroku
Aria 2 Rclone Remote URL /magnet Clouds upload via HEROKU
Stars: ✭ 99 (-78.98%)
Mutual labels:  aria2, magnet
aria2-bt-tracker
auto update aria2 bt-tracker
Stars: ✭ 35 (-92.57%)
Mutual labels:  bittorrent, aria2
Bt Btt
磁力網站U3C3介紹以及域名更新
Stars: ✭ 261 (-44.59%)
Mutual labels:  bittorrent, magnet
tinyBT
Implementation of the Bittorrent and Mainline DHT protocol for Distributed Computing applications
Stars: ✭ 30 (-93.63%)
Mutual labels:  bittorrent, dht
Zsky
DHT磁力链接magnet BT搜索引擎,纯Python开发
Stars: ✭ 256 (-45.65%)
Mutual labels:  dht, magnet
dhtrobot
A kademila DHT implement in go
Stars: ✭ 40 (-91.51%)
Mutual labels:  bittorrent, dht
btrackers-postman
btrackers-postman - BitTorrent Trackers Postman, fetch BitTorrent Trackers URL list from ngosang/trackerslist and post to your aria2 server via jsonrpc.
Stars: ✭ 13 (-97.24%)
Mutual labels:  bittorrent, aria2
Create Torrent
Create .torrent files
Stars: ✭ 264 (-43.95%)
Mutual labels:  bittorrent, browser
Dhtspider
Bittorrent dht network spider
Stars: ✭ 302 (-35.88%)
Mutual labels:  dht, bittorrent

aria2.js

JavaScript (Node.js and browsers) library for aria2, "The next generation download utility."

Introduction

aria2.js controls aria2 via its JSON-RPC interface and features

  • Node.js and browsers support
  • multiple transports
  • promise API

See aria2 methods and aria2 notifications.

Getting started

Start aria2 with rpc, example:

aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all

Install aria2.js

npm install aria2

Usage

const Aria2 = require("aria2");
const aria2 = new Aria2([options]);

default options match aria2c defaults and are

{
  host: 'localhost',
  port: 6800,
  secure: false,
  secret: '',
  path: '/jsonrpc'
}

secret is optional and refers to --rpc-secret. If you define it, it will be added to every call for you.

If the WebSocket is open (via the open method) aria2.js will use the WebSocket transport, otherwise the HTTP transport.

The "aria2." prefix can be omitted from both methods and notifications.

open

aria2.open() opens the WebSocket connection. All subsequent requests will use the WebSocket transport instead of HTTP.

aria2
  .open()
  .then(() => console.log("open"))
  .catch((err) => console.log("error", err));

close

aria2.close() closes the WebSocket connection. All subsequent requests will use the HTTP transport instead of WebSocket.

aria2
  .close()
  .then(() => console.log("closed"))
  .catch((err) => console.log("error", err));

call

aria2.call() calls a method. Parameters are provided as arguments.

Example using addUri method to download from a magnet link.

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" });

multicall

aria2.multicall() is a helper for system.multicall. It returns an array of results or throw if any of the call failed.

const multicall = [
  [methodA, param1, param2],
  [methodB, param1, param2],
];

const results = await aria2.multicall(multicall);

batch

aria2.batch() is a helper for batch. It behaves the same as multicall except it returns an array of promises which gives more flexibility in handling errors.

const batch = [
  [methodA, param1, param2],
  [methodB, param1, param2],
];

const promises = await aria2.batch(batch);

listNotifications

aria2.listNotifications() is a helper for system.listNotifications. The difference with aria2.call('listNotifications') is that it removes the "aria2." prefix from the results.

const notifications = await aria2.listNotifications();
/*
[
  'onDownloadStart',
  'onDownloadPause',
  'onDownloadStop',
  'onDownloadComplete',
  'onDownloadError',
  'onBtDownloadComplete'
]
*/

// notifications logger example
notifications.forEach((notification) => {
  aria2.on(notification, (params) => {
    console.log("aria2", notification, params);
  });
});

listMethods

aria2.listMethods() is a helper for system.listMethods. The difference with aria2.call('listMethods') is that it removes the "aria2." prefix for the results.

const methods = await aria2.listMethods();
/*
[ 'addUri',
  [...]
  'system.listNotifications' ]

*/

events

// emitted when the WebSocket is open.
aria2.on("open", () => {
  console.log("aria2 OPEN");
});

// emitted when the WebSocket is closed.
aria2.on("close", () => {
  console.log("aria2 CLOSE");
});

// emitted for every message sent.
aria2.on("output", (m) => {
  console.log("aria2 OUT", m);
});

// emitted for every message received.
aria2.on("input", (m) => {
  console.log("aria2 IN", m);
});

Additionally every aria2 notifications received will be emitted as an event (with and without the "aria2." prefix). Only available when using WebSocket, see open.

aria2.on("onDownloadStart", ([guid]) => {
  console.log("aria2 onDownloadStart", guid);
});

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].