fent/node-torrent

Double announce list

SimoMay opened this issue · 2 comments

Hey,
I'm trying to edit a torrent file by adding tracker urls to it but the module add new metadata called "announceList" instead of override the normal "announce-list". (Code below)

Image of the problem

var fs = require('fs');
var nt = require('nt');
nt.read('http://www.legittorrents.info/download.php?id=fc8a15a2faf2734dbb1dc5f7afdc5c9beaeb1f59&f=Ubuntu%2015.04%20Desktop%20(64-bit).torrent', function(err, torrent) {
  if (err) throw err;
  console.log(torrent.metadata);

  var tmpOutput = 'torrent-file.tmp';

   // Edit torrent object.
   var metadata = torrent.metadata;

   metadata.announceList = [["udp://galliumsurfer.tk:6969/announce"], ["udp://galliumsurfer.tk:69/announce"]];

   // Write new torrent file.
    var ws = torrent.createWriteStream(tmpOutput);

    ws.on('close', function() {
      fs.rename(tmpOutput, 'torrent-file.torrent', function(err) {
        if (err) throw err;

        console.log('File written to');
      });
    });
});
fent commented

announceList can be part of the options.
https://github.com/fent/node-torrent#makeannounceurl-dir-files-options-callbackerror-torrent

But announce-list is the metadata key
https://github.com/fent/node-torrent#torrentmetadata

Sorry for the confusion. Maybe it should be changed so that it's announce-list in both.

So it's more like this:
metadata["announce-list"] = [["udp://galliumsurfer.tk:6969/announce"], ["udp://galliumsurfer.tk:69/announce"]];
Thanks for explaining, nice project btw 😄