lu

library-utorrent

Communicate with uTorrent client API to list and add torrents.

Showing:

Popularity

Downloads/wk

15

GitHub Stars

1

Maintenance

Last Commit

5yrs ago

Contributors

2

Package

Dependencies

2

Size (min+gzip)

58.7KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

library-utorrent

Communicate with uTorrent Web API to list and add torrents, wraps the uTorrent Web API: http://help.utorrent.com/customer/portal/topics/664593/articles

Installation

$ npm install library-utorrent --save

Usage

Load the library:

var UTorrent = require('library-utorrent');

Add a Torrent file:

UTorrent.addTorrent({
  host: 'localhost',
  port: 26085,
  username: 'admin',
  password: '12345',
  torrentContents: fileBufferWithTorrentContent,
  downloadDir: 0,
  path: '/dir/path/',
}).exec({
  // An unexpected error occurred.
  error: function (err){

  },
  // OK.
  success: function (){

  }
});

Add a Torrent url:

UTorrent.addTorrentUrl({
  host: 'localhost',
  port: 26085,
  username: 'admin',
  password: '12345',
  torrentUrl: urlOrMagnet,
  downloadDir: 0,
  path: '/dir/path/',
}).exec({
  // An unexpected error occurred.
  error: function (err){

  },
  // OK.
  success: function (){

  }
});

List all Torrents and details:

UTorrent.listTorrents({
  host: 'localhost',
  port: 26085,
  username: 'admin',
  password: '12345',
}).exec({
// An unexpected error occurred.
  error: function (err){

  },
  // OK.
  success: function (torrents){
    /*
    torrents is an array of objects:
    [{
      parsed: {
        hash,
        name,
        size
        percentProgressMils,
        downloadedBytes,
        uploadedBytes,
        ratioMils,
        uploadspeedBytesSec,
        downloadspeedBytesSec,
        etaSec,
        peersConnected,
        peersSwarm,
        seedsConnected,
        seedsSwarm,
        availability,
        queueOrder,
        remainingBytes,
        torrentUrl,
        status,
        downloadDir
      },
      raw
    }, ...]
    */
  }
});

List Torrent Contents:

UTorrent.getTorrentDetails({
  host: 'localhost',
  port: 26085,
  username: 'admin',
  password: '12345',
  hash: 'torrentHash'
}).exec({
// An unexpected error occurred.
  error: function (err){

  },
  // OK.
  success: function (result){
    /*
    {
      "build": BUILD NUMBER (integer),
      "files": [
      HASH (string),
      [
      [
      FILE NAME (string),
      FILE SIZE (integer in bytes),
      DOWNLOADED (integer in bytes),
      PRIORITY* (integer)   ],
      ...
      ]
      ]
    }
    */
  }
});

Remove, start and stop torrent:

UTorrent.removeTorrent({...credentials, hash: 'torrentHash'}) // remove or removedata (with param removedata=true)
UTorrent.startTorrent({...credentials, hash: 'torrentHash'}) // start or forcestart (with param force=true)
UTorrent.stopTorrent({...credentials, hash: 'torrentHash'})

Retrieve uTorrent settings:

UTorrent.getsettings({
  host: 'localhost',
  port: 26085,
  username: 'admin',
  password: '12345'
}).exec({
  // An unexpected error occurred.
  error: function (err){

  },
  // OK.
  success: function (result){
    /*
    {
      "build": BUILD NUMBER (integer),
      "settings": [
      [
      OPTION NAME (string),
      TYPE* (integer),
      VALUE (string)    ],
      ...
      ]
    }
    */
  }
});
  • OPTION NAME is the name of the setting. They are not listed here, as some of the settings (particularly advanced ones) vary with each version and most are self-explanatory
  • TYPE is an integer value that indicates what type of data is enclosed within the VALUE string. The following is a list of the possible TYPEs and what VALUE type it corresponds to:
    • 0 = Integer
    • 1 = Boolean
    • 2 = String

Set uTorrent settings:

UTorrent.setSettings({
  host: 'localhost',
  port: 26085,
  username: 'admin',
  password: '12345',
  name: settingName,
  value: settingValue
}).exec({
  // An unexpected error occurred.
  error: function (err){

  },
  // OK.
  success: function (){

  }
});

About

This is the new mantained version of the library.

(Used by https://github.com/geco/utorrent-console)

License

MIT © 2016 contributors

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100