filesnax.blogg.se

How to open a torrent file using node.js
How to open a torrent file using node.js







how to open a torrent file using node.js

This tutorial is also available as a video: If you find this tutorial helpful, please share it with your friends and colleagues!įor more tutorials like this, follow me on Twitter file = engine.filesĪ file in the torrent.All code from this tutorial as a complete package is available in this repository. With this you can know how much you downloaded and how many bytes you still have to download to reach the end of the file. Listen for incoming peers on the specified port. Optionally, only remove cache and temporary data but keep downloaded pieces engine.listen(, cb) Destroys all connections to peers nnect('127.0.0.0:6881')Ĭonnect to a peer manually engine.disconnect('127.0.0.1:6881')ĭisconnect from a peer manually engine.block('127.0.0.1:6881')ĭisconnect from a peer and add it to the blocklist, preventing any other connection to it engine.remove(, cb)Ĭompletely remove all saved data for this torrent. See the file section for more info on what methods the file has stroy(cb)ĭestroy the engine. engine.filesĪn array of all files in the torrent. engine.on('idle', fn)Įmitted when all selected files have been completely downloaded. engine.on('torrent', fn)Įmitted when the metadata has been fetched. engine.on('upload', )Įmitted everytime a piece is uploaded. The files array will be empty until this event is emitted engine.on('download', )Įmitted everytime a piece has been downloaded and verified. Storage: myStorage() // Use a custom storage backend rather than the default disk-backed oneĮmitted when the engine is ready to be used. Allows to declare additional custom trackers to use Tracker: true, // Whether or not to use trackers from torrent file or magnet link Verify: true, // Verify previously stored data before startingĭht: true, // Whether or not to use DHT to initialize the swarm.

how to open a torrent file using node.js

Path: '/tmp/my-file', // Where to save the files. Full API engine = torrentStream(magnet_link_or_buffer, opts)Ĭreate a new engine instance. When you start torrent-stream it will connect to the torrent dhtĪnd fetch pieces according to the streams you create. If you want to fetch a file without creating a stream you should use the lect and select methods. Per default no files are downloaded unless you create a stream to them. You can pass start and end options to stream to slice the file // get a stream containing bytes 10-100 inclusive. stream is readable stream to containing the file content Var engine = torrentStream('magnet:my-magnet-link') var torrentStream = require('torrent-stream') Torrent-stream is a node module that allows you to access files inside a torrent as node streams. The streaming torrent engine that peerflix uses npm install torrent-stream









How to open a torrent file using node.js