Closed smolleyes closed 9 years ago
Try downloading it with {responseType:'arraybuffer'} and then converting it to a
UInt8Array`
How did you ever get this working @smolleyes ?
I think I tried all I can think of.. tried decoding iso-8859-1
to utf-8
with iconv-lite
, saving to files, sending as array buffer, UInt8Array buffer, tried XMLHttpRequest
, node-request
and node-http
.
If it's a UInt8Array
I get the error that it's not a torrent or magnet link. Otherwise, if it's a buffer I get the error that some character at point ... is wrong. If I save it to a binary
or ascii
encoded file or string it gets the wrong torrent hash and never finds any peers.
I tested with multiple torrent files from torcache.net (all torrents are encoded with iso-8859-1
on their server)
@jaruba torrents are binary files. if you have trouble getting this to work you can generate a magnet link instead by doing magnet:?xt=urn:sha1:{infohash}
Then shouldn't this work:
var request = require("request");
var requestOptions = { encoding: null, url: torLink };
request(requestOptions, function(error, response, body) {
peerflix("magnet:\?xt=urn:sha1:"+require('crypto').createHash('sha1').update(body).digest('hex'));
});
But I'm getting:
Uncaught Error: You must pass a valid torrent or magnet link - peerflix/node_modules/torrent-stream/index.js:69
Shouldn't it be magnet:?xt=urn:btih:{infoHash}
instead of magnet:?xt=urn:sha1:{infohash}
?
Also @jaruba, you should probably use read-torrent for what you're trying to do.
This worked great:
var readTorrent = require('read-torrent');
readTorrent(torLink, function(err, torrent) {
peerflix("magnet:\?xt=urn:btih:"+torrent["infoHash"]);
});
If I only knew about this 24 hours ago.. Thanks a lot. :)
You can just pass the torrent:
var readTorrent = require('read-torrent');
readTorrent(torLink, function(err, torrent) {
peerflix(torrent);
});
Even better, thanks. :)
hi
i have some difficulties to download and write torrents from a private tracker to file (or buffer) and pass it to torrent-stream...
i can get a blob of my torrent thru $ajax
Blob {type: "application/x-bittorrent", size: 14462, slice: function}
how can i do to convert / use this blob with torrent-stream :/ ?
thanks