mafintosh / torrent-stream

The low level streaming torrent engine that peerflix uses
MIT License
1.94k stars 227 forks source link

Torrent-stream does not detect files #142

Open tsoernes opened 8 years ago

tsoernes commented 8 years ago

Hi.

I have a simple function:

function play(magnet) {
    var torrentStream = require('torrent-stream');
    console.log("Creating torrent stream for " + magnet);
    var engine = torrentStream(magnet);

    engine.on('ready', function() {
        engine.files.forEach(function(file) {
            console.log('filename:', file.name);
            var stream = file.createReadStream();
            // stream is readable stream to containing the file content
        });
    });
}

to which I pass this link: magnet:?xt=urn:btih:02b6b3ed991edb7f173469f5bf8d8267 7380ea53&tr=http://tracker.torrentleech.org:2710/a/xxxxxx6xxexx44xxa01X772601xxdfc/announce. (login token hidden)

The link works If i open it manually in a torrent program, but console.log('filename:', file.name); does not print anything. Nothing happens, execution stops and nothing gets printed. Why?

mafintosh commented 8 years ago

Try console.log'ing in the ready handler and see if the event is fired

tsoernes commented 8 years ago

Like this engine.on(console.log('ready'), function() ? Yes, it is fired.

tsoernes commented 8 years ago

console.log('filename:', file.name) should fire even if the all the files are in a top-level directory, right? If not, how to get the files inside the directory?

tsoernes commented 8 years ago

@mafintosh what does it mean that the ready handler event is fired, but that no files show up? It's a private tracker, if that means anything.

mafintosh commented 8 years ago

@tsoernes does this fire?

engine.on('ready', function () {
  console.log('ready')
})
tsoernes commented 8 years ago

@mafintosh No. I also tried replacing : and / in the magnet link with %3A and %2F, but no luck.

tsoernes commented 8 years ago

@mafintosh the tracker FAQ says: "You have to turn off DHT, Peer Exchange, Local Peer Discovery and DNA in your client. " I tried turning DHT off, but no luck: the ready event is not fired, but execution finishes (it does not with dht:true).

I will also add that dragging and dropping torrent files from this particular tracker does work with popcorn-time, which uses peer-flix.

tsoernes commented 8 years ago

Take a look: DHT Off: tlscrape1 DHT On (never finishes): tlscrape2

This is a very strange issue. If I try the magnet link in peerflix-cli, it does not work, but if I download the torrent-file and put it in the cli, it works. Do you have any idea what it could be? I can email you a torrent if that would help.

This is a possible workaround, but it's not pretty:

// Torrent location is relative to the location of this script
    var spawn = require('child_process').spawn;
    var child = spawn('cmd', ['/c', 'peerflix', torrentFilePath, "--mpchc"]);
    child.on('error', function (err) {
        console.log('Failed to start child process.');
    });
williamsbs commented 5 years ago

hi i still have this probleme, some magnets don't trigger the engine.on('ready', fn), does anyone have a solution ?