2.0.2 • Published 7 years ago

powersteer v2.0.2

Weekly downloads
-
License
AGPL-3.0
Repository
gitlab
Last release
7 years ago

Egeria Powersteer

NPM version Downloads

About

Powersteer lets you communicate with Transmission.

It provides access to the entire Transmission API and performs checks on arguments before sending anything to transmission-daemon.

Creating a new client

Require Powersteer and create a new client:

var Powersteer = require('powersteer');

var rpc = new Powersteer({
    url: 'http://my.box.ip:9091/transmission/rpc',
    username: 'mysides',
    password: 'theyaregone'
});

The constructor accepts an object with the following fields:

url (mandatory)

Self-explanatory enough, but make sure you don't simply give the ip and port of your box; Transmission listens for RPC calls on a specific HTTP address. If we assume the Transmission instance to be installed locally, the default address is 'http://127.0.0.1:9091/transmission/rpc'.

username (optional)

If you ave secured your Transmission daemon, put your username here.

password (optional)

If you have provided a username, the password becomes mandatory. The constructor will throw if you don't provide one.

If you set one of the fields username and password to any value that isn't null, the other field becomes mandatory.

Using a client

I tried to follow Transmission's docs as closely as possible.

These are the methods available in Powersteer with the respective Transmission procedures:

PowersteerTransmission
torrentStart'torrent-start'
torrentStartNow'torrent-start-now'
torrentStop'torrent-stop'
torrentVerify'torrent-verify'
torrentReannounce'torrent-reannounce'
torrentSet'torrent-set'
torrentGet'torrent-get'
torrentAdd'torrent-add'
torrentRemove'torrent-remove'
torrentSetLocation'torrent-set-location'
torrentRenamePath'torrent-rename-path'
sessionSet'session-set'
sessionGet'session-get'
sessionStats'session-stats'
blocklistUpdate'blocklist-update'
portTest'port-test'
sessionClose'session-close'
queueMoveTop'queue-move-top'
queueMoveUp'queue-move-up'
queueMoveDown'queue-move-down'
queueMoveBottom'queue-move-bottom'
freeSpace'free-space'

torrentStart, torrentStartNow, torrentStop, torrentVerify, torrentReannounce

Arguments: a list of torrent ids in the form:

{
    ids: [1, 2, 3, ...]
}

torrentSet

Arguments:

FieldTypeDescription
bandwidthPriorityNumberthis torrent's bandwidth tr_priority_t
downloadLimitNumbermaximum download speed (KBps)
downloadLimitedBooleantrue if downloadLimit is honored
files-wantedArrayindices of file(s) to download
files-unwantedArrayindices of file(s) to not download
honorsSessionLimitsBooleantrue if session upload limits are honored
idsArraylist of torrent ids; if empty, it means "all torrents"
locationStringnew location of the torrent's content
peer-limitNumbermaximum number of peers
priority-highArrayindices of high-priority file(s)
priority-lowArrayindices of low-priority file(s)
priority-normalArrayindices of normal-priority file(s)
queuePositionNumberposition of this torrent in its queue [0...n)
seedIdleLimitNumbertorrent-level number of minutes of seeding inactivity
seedIdleModeNumberwhich seeding inactivity to use. See tr_idlelimit
seedRatioLimitNumbertorrent-level seeding ratio
seedRatioModeNumberwhich ratio to use. See tr_ratiolimit
trackerAddArraystrings of announce URLs to add
trackerRemoveArrayids of trackers to remove
trackerReplaceArraypairs of <trackerId/new announce URLs>
uploadLimitNumbermaximum upload speed (KBps)
uploadLimitedBooleantrue if uploadLimit is honored

You must specify at least one.

torrentGet

Arguments: a list of fields to retrieve in the form:

{
    fields: ['field1', 'field2', 'field3', ...]
}

You must be precise. The correct name of every available field is in the docs, section "3.3".

torrentAdd

Arguments:

FieldTypeDescription
cookiesStringpointer to a string of one or more cookies.
download-dirStringpath to download the torrent to
filenameStringfilename or URL of the .torrent file
metainfoStringbase64-encoded .torrent content
pausedBooleanif true, don't start the torrent
peer-limitNumbermaximum number of peers
bandwidthPriorityNumbertorrent's bandwidth tr_priority_t
files-wantedArrayindices of file(s) to download
files-unwantedArrayindices of file(s) to not download
priority-highArrayindices of high-priority file(s)
priority-lowArrayindices of low-priority file(s)
priority-normalArrayindices of normal-priority file(s)

torrentRemove

Arguments: a list of torrent ids and a Boolean delete-local-data field (when true, delete all downloaded files belonging to the removed torrents).

torrentSetLocation

Arguments:

FieldTypeDescription
idsArraytorrent list
locationStringthe new download location
moveBooleanif true, move from previous location. otherwise, search "location" for files (default: false)

torrentRenamePath

See the docs, section "3.7".

TODO (available but undocumented)

sessionSet, sessionGet, sessionStats, blocklistUpdate, portTest, sessionClose, queueMoveTop, queueMoveUp, queueMoveDown, queueMoveBottom, freeSpace

See the docs

Example

var Powersteer = require('powersteer');

var trace = (x) => {console.log('TRACE: ', x); return x;};

var rpc = new Powersteer({url: 'http://my.box.ip:9091/transmission/rpc'});

rpc.torrentGet({fields: ['id', 'name', 'percentDone']}).then(trace).catch(trace);

rpc.torrentAdd({filename: 'http://cdimage.debian.org/debian-cd/8.2.0/amd64/bt-cd/debian-8.2.0-amd64-CD-1.iso.torrent', paused: true}).then(trace).catch(trace);
2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

1.0.0-rc.1

8 years ago

1.0.0-rc.0

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.2

8 years ago

0.0.1

9 years ago