Add peer and file data to torrent detail retrieval

This commit is contained in:
John Furrow
2015-11-21 23:19:16 -08:00
parent 4e76edb9a6
commit 345825c02c
2 changed files with 45 additions and 8 deletions
+27 -4
View File
@@ -52,14 +52,37 @@ var client = {
},
getTorrentDetails: function(hash, callback) {
var params = [hash, ''].concat(clientUtil.defaults.peerPropertyMethods);
rTorrent.get('p.multicall', params)
var peerParams = [hash, ''].concat(clientUtil.defaults.peerPropertyMethods);
var fileParams = [hash, ''].concat(clientUtil.defaults.filePropertyMethods);
var multicall = [
[]
];
multicall[0].push({
methodName: 'p.multicall',
params: peerParams
});
multicall[0].push({
methodName: 'f.multicall',
params: fileParams
});
rTorrent.get('system.multicall', multicall)
.then(function(data) {
var peers = clientUtil.mapClientProps(
clientUtil.defaults.peerProperties,
data
data[0][0]
);
callback(null, peers);
var files = clientUtil.mapClientProps(
clientUtil.defaults.fileProperties,
data[1][0]
);
callback(null, {
peers: peers,
files: files
});
}, function(error) {
callback(error, null);
});
+18 -4
View File
@@ -31,8 +31,8 @@ var clientUtil = {
'peersNotConnected',
'trackerFocus',
'basePath',
'creationDate',
'directory',
'filename',
'seeding',
'added'
@@ -68,12 +68,26 @@ var clientUtil = {
'd.get_peers_not_connected=',
'd.get_tracker_focus=',
'd.get_base_path=',
'd.get_creation_date=',
'd.get_directory=',
'd.get_base_filename=',
'd.get_custom=seedingtime',
'd.get_custom=addtime'
],
fileProperties: [
'path',
'pathComponents',
'pathDepth',
'priority',
'sizeBytes'
],
filePropertyMethods: [
'f.get_path=',
'f.get_path_components=',
'f.get_path_depth=',
'f.get_priority=',
'f.get_size_bytes='
],
clientProperties: [
'uploadRate',
'uploadTotal',