Skip to content

Commit

Permalink
Updated example to use hash and not id
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim committed May 13, 2014
1 parent 53bf630 commit 9760e62
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions example.js
Expand Up @@ -7,20 +7,21 @@ var transmission = new Transmission({
});


function get(id, cb) {
transmission.get(id, function(err, result) {
function get(hash, cb) {
transmission.get(hash, function(err, result) {
if (err) {
throw err
}
cb(null, result.torrents[0]);
});
};

function watch(id) {
get(id, function(err, torrent) {
function watch(hash) {
get(hash, function(err, torrent) {
if (err) {
throw err;
}

var downloadedEver = 0;
var WatchBar = new ProgressBar(' downloading [:bar] :percent :etas', {
complete : '=',
Expand All @@ -41,16 +42,16 @@ function watch(id) {
return remove(id);
}
setTimeout(function() {
get(id, tick);
get(hash, tick);
}, 1000);
}

get(id, tick);
get(hash, tick);
});
}

function remove(id) {
transmission.remove(id, function(err) {
function remove(hash) {
transmission.remove(hash, function(err) {
if (err) {
throw err
}
Expand All @@ -64,6 +65,6 @@ transmission.addUrl('http://cdimage.debian.org/debian-cd/current/i386/bt-cd/debi
if (err) {
return console.log(err);
}
var id = result.id;
watch(id);
var hash = result.hashString;
watch(hash);
});

0 comments on commit 9760e62

Please sign in to comment.