UNPKG

aria2-client

Version:

A download client based on aria2 (a lightweight multi-protocol & multi-source, cross platform download utility operated in command-line. It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink)

145 lines 4.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Aria2 = require("aria2"); class Aria2Client { constructor(config = { host: 'localhost', port: 6800, secure: false, secret: '', path: '/jsonrpc', }) { this.aria2 = new Aria2(config); } async open() { return await this.aria2.open(); } async close() { return await this.aria2.close(); } async addUri(uris, { dir }) { return await this.aria2.call('addUri', uris, { dir }); } async addTorrent(torrent) { return await this.aria2.call('addTorrent', torrent); } async addMetalink(metalink) { return await this.aria2.call('addMetalink', metalink); } async remove(gid) { return await this.aria2.call('remove', gid); } async forceRemove(gid) { return await this.aria2.call('forceRemove', gid); } async pause(gid) { return await this.aria2.call('pause', gid); } async pauseAll() { return await this.aria2.call('pauseAll'); } async forcePause(gid) { return await this.aria2.call('forcePause', gid); } async forcePauseAll() { return await this.aria2.call('forcePauseAll'); } async unpause(gid) { return await this.aria2.call('unpause', gid); } async unpauseAll() { return await this.aria2.call('unpauseAll'); } async tellStatus(gid, keys = undefined) { return await this.aria2.call('tellStatus', gid, keys); } async getUris(gid) { return await this.aria2.call('tellStatus', gid); } async getFiles(gid) { return await this.aria2.call('getFiles', gid); } async getPeers(gid) { return await this.aria2.call('getPeers', gid); } async getServers(gid) { return await this.aria2.call('getPeers', gid); } async tellActive() { return await this.aria2.call('tellActive'); } async tellWaiting(offset, num) { return await this.aria2.call('tellWaiting', offset, num); } async tellStopped(offset, num) { return await this.aria2.call('tellStopped', offset, num); } async changePosition(gid, pos, how) { return await this.aria2.call('changePosition', gid, pos, how); } async changeUri(gid, fileIndex, delUris, addUris) { return await this.aria2.call('changeUri', gid, fileIndex, delUris, addUris); } async getOption(gid) { return await this.aria2.call('getOption', gid); } async changeOption(gid, options) { return await this.aria2.call('changeOption', gid, options); } async getGlobalOption() { return await this.aria2.call('getGlobalOption'); } async changeGlobalOption(options) { return await this.aria2.call('changeGlobalOption', options); } async getGlobalStat() { return await this.aria2.call('getGlobalStat'); } async purgeDownloadResult() { return await this.aria2.call('purgeDownloadResult'); } async removeDownloadResult(gid) { return await this.aria2.call('removeDownloadResult', gid); } async getVersion() { return this.aria2.call('getVersion'); } async getSessionInfo() { return this.aria2.call('getSessionInfo'); } async shutdown() { return this.aria2.call('shutdown'); } async forceShutdown() { return this.aria2.call('forceShutdown'); } async saveSession() { return this.aria2.call('saveSession'); } async onOpen(callback) { this.aria2.on('open', callback); } async onClose(callback) { this.aria2.on('close', callback); } async onDownloadStart(callback) { this.aria2.on('onDownloadStart', callback); } async onDownloadPause(callback) { this.aria2.on('onDownloadPause', callback); } async onDownloadStop(callback) { this.aria2.on('onDownloadStop', callback); } async onDownloadComplete(callback) { this.aria2.on('onDownloadComplete', callback); } async onDownloadError(callback) { this.aria2.on('onDownloadError', callback); } async onBtDownloadComplete(callback) { this.aria2.on('onBtDownloadComplete', callback); } } exports.default = Aria2Client; //# sourceMappingURL=aria2-client.service.js.map