aria2.js
JavaScript library for aria2, "The next generation download utility."
Use
Install
npm install aria2
Browsers
<script src="aria2.js/lib/index.js"></script>
Node.js
var aria2 = require('aria2');
Example
var aria2 = new Aria2();
aria2.open('ws://127.0.0.1:6800/jsonrpc')
aria2.onopen = function() {
console.log('OPEN');
aria2.getVersion(function(err, res) {
console.log(err || res);
});
};
aria2.onclose = function() {
console.log('close');
};
aria2.onsend = function(m) {
console.log('message out:')
console.log(m);
};
aria2.onmessage = function(m) {
console.log('message in:');
console.log(m);
};
aria2.onDownloadStart = function(e) {
console.log(e);
};
Methods
See aria2 methods
For every method you can use
aria2.send(method, [params], function(err, res) {
console.log(err || res);
});
or directly
aria2.method([params], function(err, res) {
console.log(err || res);
});
Notifications
See aria2 notifications
For every notifications you can attach a function to call.
aria2.onDownloadStart = function(event) {
console.log(event);
};