node-transmission
transmission-daemon wrapper script written in node.js
Install
npm install transmission
How to Use
Transmission = require 'transmission'transmission = host: 'localhost' # default 'localhost' port: 9091 # default 9091 username: 'username' # default blank password: 'password' # default blank ssl: true # default false use https url: '/my/other/url' # default '/transmission/rpc'
Definition
Status
RPC returned torrent status with integer 0-7
.
Using transmission.status
for inspect status.
transmission.status =
STOPPED : 0 # Torrent is stopped
CHECK_WAIT : 1 # Queued to check files
CHECK : 2 # Checking files
DOWNLOAD_WAIT : 3 # Queued to download
DOWNLOAD : 4 # Downloading
SEED_WAIT : 5 # Queued to seed
SEED : 6 # Seeding
ISOLATED : 7 # Torrent can't find peers
Methods
transmission.set([ids], callback)
Set torrent's properties.
transmission;
You must provide one or more ids. According to the rpc-spec, transmission will not respond a success argument. Only error.
transmission.addFile(filePath, callback)
Add torrents to transmission-daemon.
transmission;
OR
The options
object would be the arguments passed to transmission.
If you want to set the download directory of the torrent you would pass in "download-dir":"/my/path"
transmission;
transmission.addUrl(url, callback)
Add torrents to transmission-daemon.
transmission;
OR
The options
object would be the arguments passed to transmission.
If you want to set the download directory of the torrent you would pass in "download-dir":"/my/path"
transmission;
transmission.remove(ids, del, callback)
Remove torrents.
Remove also local data when del
is true
.
transmission;
transmission.active(callback)
List of active torrents. Callback is not needed and will fire the active
event.
transmission;
transmission.get([ids], callback)
Get torrents info that optional ids
.
If omit ids
, get all torrents.
transmission; # Get all torrents and remove it if status is stoppedtransmission;
transmission.waitForState(id, targetState, callback)
Polls the server and waits for the target state. targetState = ['STOPPED', 'CHECK_WAIT', 'CHECK', 'DOWNLOAD_WAIT', 'DOWNLOAD', 'SEED_WAIT', 'SEED', 'ISOLATED'];
transmission;
transmission.stop(ids, callback)
Stop working torrents.
transmission;
transmission.start(ids, callback)
Start working torrents.
transmissionstartids {};
transmission.startNow(ids, callback)
Bypass the download queue, start working torrents immediately.
transmission;
transmission.verify(ids, callback)
Verify torrent data.
transmission;
transmission.reannounce(ids, callback)
Reannounce to the tracker, ask for more peers.
transmission;
transmission.session(callback)
Get client session infomation.
transmission;
transmission.session({}, callback)
Set session infomation.
transmission;
transmission.sessionStats(callback)
Get client session stats.
transmission;
transmission.freeSpace(path, callback)
Get free space available on the server for the specified directory.
transmission;
All together.
'use strict'; var Transmission = ;var transmission = port: 9091 // DEFAULT : 9091 host: 192168134 // DEAFULT : 127.0.0.1 username: 'username' // DEFAULT : BLANK password: 'password' // DEFAULT : BLANK; // Get details of all torrents currently queued in transmission app{ transmission;} // Add a torrent by passing a URL to .torrent file or a magnet link{ transmission;} // Get various stats about a torrent in the queue { transmission;} { transmission;} // To start a paused / stopped torrent which is still in queue{ transmissionstartid {};} // To get list of all torrents currently in queue (downloading + paused)// NOTE : This may return null if all torrents are in paused state { transmission;} // Pause / Stop a torrent{ transmission;} // Pause / Stop all torrent{ transmission;} // Remove a torrent from download queue// NOTE : This does not trash torrent data i.e. does not remove it from disk { transmission;} // Get torrent state{ return transmissionstatusArraytype iftype === 0 return 'STOPPED'; else iftype === 1 return 'CHECK_WAIT'; else iftype === 2 return 'CHECK'; else iftype === 3 return 'DOWNLOAD_WAIT'; else iftype === 4 return 'DOWNLOAD'; else iftype === 5 return 'SEED_WAIT'; else iftype === 6 return 'SEED'; else iftype === 7 return 'ISOLATED'; }