mafintosh / torrent-stream

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

question : how to stream only one file of the torrent #95

Open smolleyes opened 9 years ago

smolleyes commented 9 years ago

hi

how can i do if for exemple

i open a torrent of 20 avi files, when ready i load a popup with a list of all available file sin the torrent, now how can i tell torrent-stream to select and download only this file ? (if possible)

thanks :)

asapach commented 9 years ago

Torrent-stream doesn't start downloading files automatically - you need to do this explicitly. Just call file.select() or file.createReadStream(opts) and it will start downloading this file.

smolleyes commented 9 years ago

hello

ok thanks i ll try this :p

smolleyes commented 9 years ago

hi

is it possible to, for exemple

i give a torrent to read-torrent, i get the files list and file list have many files...

how can i directly tell torrent-stream (or peerflix in my case) to download the file with the id of my file in the list array ?

i do it later for the moment in my code and in the /tmp/torrent-stream folder i see two or three avi files created not just the one i selected :/

thanks!

emanuelpessoaa commented 9 years ago

@smolleyes if you only call peerflix command within a node app via spawn/whatever/etc, for to select a array value you can use the Inquirer module for show Choices[array] with their Values and a Action for the value selected. However, it works if your node app is command-line, and you'll have to make a command line based in your need before this. You got it? maybe confused. lol

This is an alternative for a specific case.

But, about the API... I have a same problem to download a unique file specific. file.select() or file.createReadStream(opts) no works for me.

:(

smolleyes commented 9 years ago

hi

fixed it a long time ago now everything works very well for me :p i can display an ordered table (i filter it thru underscore) then just start the good index and it works

Le 02/04/2015 16:47, Emanuel Pessoa a écrit :

@smolleyes https://github.com/smolleyes if you only call peerflix command within a node app via spawn/whatever/etc, for to select a array value you can use the Inquirer module for show Choices[array] with their Values and a Action for the value selected. However, it works if your node app is command-line, and you'll have to make a command line based in your need before this. You got it? maybe confused. lol

This is an alternative for a specific case.

But, about the API... I have a same problem to download a unique file specific. file.select() or file.createReadStream(opts) no works for me.

:(

— Reply to this email directly or view it on GitHub https://github.com/mafintosh/torrent-stream/issues/95#issuecomment-88933515.

ghost commented 9 years ago

using the API you can download a specific torrent using something like

var torrentStream = require('torrent-stream');

var engine = torrentStream('magnet:my-magnet-link');

engine.on('ready', function() {
    engine.files.forEach(function(file) {
        if(file.name == "somefile.avi") {
            var stream = file.createReadStream();
        }
    });
});
noamanahmed commented 9 years ago

Hi I am new to node I am trying to use this library to stream torrent contents. My server.js file

var http = require('http'), fs = require('fs'), url = require('url'),
torrentStream = require('torrent-stream'), magnet ='magnet:?xt=urn:btih:85647B1484F8288EB2891BF6BED677BC5C57ECF8&dn=ted+2+2015+uncensored+hc+1080p+hdrip+1+8gb+shaanig&tr=udp%3A%2F%2Ftracker.publicbt.com%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337', engine = torrentStream(magnet), port = 10101; console.log(engine); 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
    });
});

engine.on('download', function() {
    console.log('downloaded');
});
torrentfile = engine.files;
console.log(torrentfile);

I know there is a lot of console.log But since I couldn't get it running so I did it.Then I run from command line

node server I get this

{ domain: null, _events: {}, _maxListeners: 10, ready: [Function], infoHash: '85647b1484f8288eb2891bf6bed677bc5c57ecf8', metadata: null, path: '/tmp/torrent-stream/85647b1484f8288eb2891bf6bed677bc5c57ecf8', files: [], selection: [], torrent: null, bitfield: null, amInterested: false, store: null, swarm: { domain: null, _events: { wire: [Function] }, _maxListeners: 10, handshake: undefined, port: 0, size: 100, utp: false, handshakeTimeout: 25000, connectTimeout: 3000, infoHash: <Buffer 85 64 7b 14 84 f8 28 8e b2 89 1b f6 be d6 77 bc 5c 57 ec f8>, peerId: <Buffer 2d 54 53 30 30 30 38 2d 61 33 35 65 31 64 38 61 65 66 32 66

, downloaded: 0, uploaded: 0, connections: [], wires: [], paused: true, downloadSpeed: [Function], uploadSpeed: [Function], _destroyed: false, _queues: [ [Object] ], _peers: {}, _pwp: { speed: 10 } }, flood: [Function], pulse: undefined, critical: [Function], select: [Function], deselect: [Function], setPulse: [Function], setFlood: [Function], setFloodedPulse: [Function], connect: [Function], disconnect: [Function], block: [Function], remove: [Function], destroy: [Function], listen: [Function] }

There is simply no data returned .Could you help me what I am doing wron

ldenblyd commented 5 years ago

@smolleyes if you only call peerflix command within a node app via spawn/whatever/etc, for to select a array value you can use the Inquirer module for show Choices[array] with their Values and a Action for the value selected. However, it works if your node app is command-line, and you'll have to make a command line based in your need before this. You got it? maybe confused. lol

This is an alternative for a specific case.

But, about the API... I have a same problem to download a unique file specific. file.select() or file.createReadStream(opts) no works for me.

:(

i have the same problem even if i .select() only one file, all file of the torrent are created

engine.on('ready', () => {
            console.log('READY');
            engine.files.forEach((file) => {
                if (file.name.endsWith(".txt")) {
                    currentfile.push(file);
                    console.log(' --- DOWNLOAD:', file.name);
                } else {
                    console.log(' --- IGNORE:', file.name);
                }
            });
            if (!currentfile[0]) {
                console.log('FAIL')
                engine.removeAllListeners();
                engine.destroy();
            } else {
                console.log('SUCCESS')
                currentfile[0].createReadStream()
            }
        });
smolleyes commented 5 years ago

Hi

ouch i fixed it LOOOONGGGG TIME ago lol don t even remember the code... i think i still have it in my streamstudio repo... will check later if you want/need it :)

++

On Mon, Apr 8, 2019 at 7:00 PM Loan Denblyden notifications@github.com wrote:

@smolleyes https://github.com/smolleyes if you only call peerflix command within a node app via spawn/whatever/etc, for to select a array value you can use the Inquirer module for show Choices[array] with their Values and a Action for the value selected. However, it works if your node app is command-line, and you'll have to make a command line based in your need before this. You got it? maybe confused. lol

This is an alternative for a specific case.

But, about the API... I have a same problem to download a unique file specific. file.select() or file.createReadStream(opts) no works for me.

:(

i have the same problem event if i .select() only one file all file of the torrent are created

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mafintosh/torrent-stream/issues/95#issuecomment-480915662, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMOQACIuSKRAmCV6pYHpWiKjo7d2DBjks5ve3XKgaJpZM4DfE7R .

ldenblyd commented 5 years ago

haha thats be realy nice ^^ thanks

smolleyes commented 5 years ago

^^

just looked at the code (what a mess lol) look the handleTorrent function

https://github.com/smolleyes/StreamStudio/blob/master/js/flix.js

You need to keep a track of your file id from the torrent metadata first then send it to this function (if i remember)

Le lun. 8 avr. 2019 à 19:34, Loan Denblyden notifications@github.com a écrit :

haha thats be realy nice ^^ thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mafintosh/torrent-stream/issues/95#issuecomment-480929003, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMOQBdn3XzYyT480DefSMgaksy7c1t2ks5ve32HgaJpZM4DfE7R .

smolleyes commented 5 years ago

Look at the loadtable function too 😉

Le lun. 8 avr. 2019 à 21:41, sylvain lagui s.lagui@gmail.com a écrit :

^^

just looked at the code (what a mess lol) look the handleTorrent function

https://github.com/smolleyes/StreamStudio/blob/master/js/flix.js

You need to keep a track of your file id from the torrent metadata first then send it to this function (if i remember)

Le lun. 8 avr. 2019 à 19:34, Loan Denblyden notifications@github.com a écrit :

haha thats be realy nice ^^ thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mafintosh/torrent-stream/issues/95#issuecomment-480929003, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMOQBdn3XzYyT480DefSMgaksy7c1t2ks5ve32HgaJpZM4DfE7R .

ldenblyd commented 5 years ago

hoo nice thanks smolleyes !

ldenblyd commented 5 years ago

i see you remove torrent-stream for peerflix, i make a school project and unfortunatly we canot use peerflix or webtorrent

if someone else have the solution width torrent-stream, i take it :)