Giter VIP home page Giter VIP logo

node-torrent's Introduction

node-torrent

A simple bittorrent client for node.

Features

  • .torrent support
  • Resume
  • Seeding
  • UDP trackers
  • DHT peer discovery
  • Magnet links
  • Add torrent via URL (file:, https:, http:, magnet:)

In progress

  • Expose nice programmatic API for interacting with torrents/peers/trackers

TODO

  • Share ratio
  • Accurate reporting on download/upload speeds
  • Limit download/upload speeds
  • Persist?

Usage

var Client = require('node-torrent');
var client = new Client({logLevel: 'DEBUG'});
var torrent = client.addTorrent('a.torrent');

// when the torrent completes, move it's files to another area
torrent.on('complete', function() {
    console.log('complete!');
    torrent.files.forEach(function(file) {
        var newPath = '/new/path/' + file.path;
        fs.rename(file.path, newPath);
        // while still seeding need to make sure file.path points to the right place
        file.path = newPath;
    });
});

License

(The MIT License)

Copyright (c) 2011 Max Stewart <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-torrent's People

Contributors

alobodig avatar baggachipz avatar bencevans avatar darsee avatar davidyaha avatar diogoduailibe avatar dominictarr avatar glennporter avatar iantocristian avatar janjongboom avatar mathiscode avatar mrch4n avatar superafroman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-torrent's Issues

Never ending downloading, and event emitter issues

  • Event emitter issues appears:
    (node) warning: possible EventEmitter memory leak detected. 2 listeners added. Use emitter.setMaxListeners() to increase limit.
    Trace
    at EventEmitter.addListener (events.js:160:15)
  • Never ending (incomplete) downloading, when tracker announce error:
    [2013-09-09 10:03:31.649] [WARN] tracker.js - announce error from udp://fr33domtracker.h33t.com:3310/announce: getaddrinfo ENOTFOUND
    [2013-09-09 10:03:31.650] [WARN] tracker.js - retry announce 'started' in 5s

Announce error (403 Forbidden)

Trying to download file, but always get errors:

[2014-01-24 11:27:07.430] [WARN] tracker.js - announce error from http://bt.rutracker.org/ann?uk=0carlgMQCj: Unexpected status code: 403, response: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>403 - Forbidden</title>
 </head>
 <body>
  <h1>403 - Forbidden</h1>
 </body>
</html>

This is content of .torrent file:

d8:announce41:http://bt.rutracker.org/ann?uk=0carlgMQCj13:announce-listll41:http://bt.rutracker.org/ann?uk=0carlgMQCjel31:http://retracker.local/announceee7:comment49:http://rutracker.org/forum/viewtopic.php?t=64658910:created by13:uTorrent/177013:creation datei1202201366e8:encoding5:UTF-84:infod6:lengthi8239328e4:name34:Algorithms and data structure.djvu12:piece lengthi65536e6:pieces2520:г
ЭЫЈгИ2�'�Јг�AдО� «ЅAў(ТfгщFо»њђ�B цф¬(‚о‡Ё@иЃўЗбЏЇ1D�! ’„w§ѕ MP�.рQ·aПy?Ѓкw™ЇWЋ2;†(сЬ/sл`fХЭаuи'Ёі�ЁML�ж��Гџм�“лЌG:Ь98�­h1Р%;LГ1нж�€jр�ВПlг�З�Я‹ѓxs�аo�<о[ДТ�Ю�‡s�Ќ°�ГNюкч�д%;a™ФBx�g/ЦZ�In�T«&©UqХљЮ8ъ(.�†7$�єІї‹nЙ�z‚ШВ~�”�f�SИ]ЙWШ$°�Ъі±jЬjMcК†n�jЕЋьX
ОWбп�YЦmT2М�{O�JBяN uacy�†'A7Ві/UпЄjgжўzsc�Гa�…Аvµ�gg›–�e‘ы”{тпtёеG0О�уЫ?ЉЕUQ�S�ёSК�ыо$п¶P+О�TШ଻<%Ш%.[АEµО�н—󵄓юЋ6�ZBЩґ{^TдA�Ѕi$`пWihU
у�.5�МЪѓУхЏњ‚ќ!8ЈJ]хКъj№�*&Їi^�  G�эxо$Ф({©3гцйЪYj;"ЉuA�h–.
tЪu'ъN�:r�ч9q�sЈбЊ�Р)jUHЩ�•a«>л¦#}јвHѓ”3µѓ•�'�xwЖE{�$їl=ЌМ>нПtсI®PkҐ�ёљ�HШsмоЬ
љњ…KЂu‡CО0[­©†iAq�щ‹^‹лрo^?ЈXФy5cђПў($По��6€(ьЙhлlЙЅb�Аті»F�ч€�СH+э№эхиМ�-hўb‰”ЅЖ9Тзн№YЌш?o7^h�гКБ’П—@¦¬®Э<�¬йєbњы�0etпв�u�j‚C��ъe
�aG›tMЖБw‡bs'у~?ЋA{Цђ20АТBeu¤БM�erRяCВ�М№'†хЦЮ$l|љ�ЛазШхr–¤лBрЏ`ЄzЖ¬ЮѕµMш��i0Б�µH1$‚Q�Q�/™G�щ&&ѕ:љn¬†DЦn�/А �g��Ц�яшe)QJRYz8�М®Unт�s«hВjс.Ґ�§Ђ'R�–‡IBб�Дд[�тLD�O–©f„б{Ґ�¶еsВ*�ЊЮ�Т+¬·rP)}‡O”�_П‰TЙ­@'1>еУК;И]­ЙКБ3¶w%ЁQоLґyЋ�T•еvЉN6§©m�(nµfЂ?cЦP•N �Mв!zf>‰д�Нл]ҐЉM�©?ђvо†у'б^сFэYї4Ќ�К�Књj"IrЊНrъуҐ�т;ЕGбcGТХп�Аџ†№‹кh�xќ#xђ�6ЫйМ/dЈ&°Z1ВўU� „�‰М4Т’c��'>†™'з#kБоЃЂa4{§ѕЉт�Zп¤\�Џ итлјxL6ЃљЛ�“^„6�g€юЃСЎј ф!�g;т��mђ
СюёаHТ�ѓa+­С�ЖM-bЦ ФB>w��ЉЩuЎl¶
V��Ј™’ўT”   !mЅKќWЭъЗ—�S{юћCнЋ,хсэуcSдШ“�O|зVvZ&†ФЮqH�q€‘№1Ґ�<°ЬтI«�&H�±’•ЬЈј†Ы�]RКdАЬ3ќ©D[З„УВуьG†Оh~Ј±Ґюrбј;›ж§Zd�j�ъќф“�лaЌ–—‚\•QЎ‹{ы ЊY�- �R�ЬcѓБI�gГ¬фыOю�»Б!Ѓ�58уHо�NP"ЬНPҐшц>§ўЎqЪлс$’BУaW�ЋYp�pВ lЂє
Ј�Ш¤оЌ­Ew$’�ЭШнБ�їB`qЉt�яэ�аzџttЎшЅЅ�mSZыо$, І�bO�C:ь�—[�оj�±�ЭGЦЄяи»*Ўд6ѓ���Я    { Ы3ћ/^аFFПЉ�ґ�‹�tOЖ[‰8NШЛхЩsхtaњХжўЂЊє
В_b)Н'[Кэ_а]R[±�$®‰�).T�Їj�;Мcм%XIq±¶,i�Л%&-¶ке"NвX}0ukт±"\—A‰VSЗЌЪB}д‡krs¤m€HkGn+9ьWSэ’\�LЋ�‡С p

lж=р
nПxІєЩц�Єґkj(С1Ќ ¶�шйе%цHёС�
tяѓчЦ�ҐfЪК*©j>ќ��ХSKНЊO�r_NЋ>  JT�f–)п“р�њі'�ЬОШ»f™Џп�Ша#UнљGТЬЧъ•°uyЅЦd  vXK¤ЎT5Щ¶†�чwPWV›ЈШЉ7�®UJ�Ж�Щ…у   Ђ=‹7�}=ї�'¦^q;Љ,�'’tкі    My­‰4-D�^„uэЕ•јЦPЄH•\„Чi@иИw�ПХѕ�
z凧
�°OdЦY
sS:ыя"с'ЇwъjК¤В>JЂїЦ.ЋўµЂ'р`*F)y�Nж‹�н·№*ѓ�j€р€o@aЂ�ЂNѓ±

Is there a way to get a read stream of the downloading file?

This example only shows a way to move a downloaded file.

var Client = require('node-torrent');
var client = new Client({logLevel: 'DEBUG'});
var torrent = client.addTorrent('a.torrent');
 
// when the torrent completes, move it's files to another area
torrent.on('complete', function() {
    console.log('complete!');
    torrent.files.forEach(function(file) {
        var newPath = '/new/path/' + file.path;
        fs.rename(file.path, newPath);
        // while still seeding need to make sure file.path points to the right place
        file.path = newPath;
    });
});

317M file included in NPM

I tried to install this with npm, but it took forever.
Turns out there is a 317M .mp4 file in there. Would you mind removing it?

Load balanced UDP trackers

Hello,
I've been playing around with the Tracker class alone for the UDP protocol. i've been trying to find peers off of udp://tracker.openbittorrent.com:80/announce.
The problem is, that hostname seems to map to several ipv4 DNS records, probably for load balancing purposes. However, when sending its UDP packets, node-torrent uses the hostname everytime which causes the DNS lookup to sometime resolve to another address. In the end, this results in "connection ID missmatch" error messages from the tracker.

A fix for this could be to dns.lookup() the tracker's address once and for all at the begnning.

UDP tracker requesting status

Hello,

I'm interested in using your code for another project especially when it comes to querying UDP trackers.

Is the UDP tracker querying working? In any case, would it be OK for me to extract it as a separate module (MIT licensed, with your name) ?

Error while starting download

Uncaught node.js Error

RangeError: Port should be > 0 and < 65536
at connect (net.js:843:13)
at net.js:940:9
at dns.js:82:18
at process._tickCallback (node.js:382:11)

Magnets

Nice lib, any approximate date on when magnets will be supported?

Outdated release

Hi @superafroman,

First of all, thanks for this great module!
I've downloaded the last version from npm (npm install node-torrent) and it is clearly outdated, it doesn't contain the latest fixes.

Could you make a release with the latest code?

Thanks!
Best,
Guillermo.

some errors occurred when downloading

logs:

Listening for connections on {"address":"0.0.0.0","family":"IPv4","port":6881}
path.exists is now called fs.exists.
[2012-10-05 10:00:46.540] [DEBUG] torrent.js - Finished validating pieces. Numb
er of valid pieces = 0 out of a total of 841

D:\PG\node-torrent\node_modules\node-torrent\lib\util\bencode.js:83
throw "Can't decode. No type starts with: "+ c;
^
Can't decode. No type starts with: <

I get this all the time.

Node version 0.10.1 and validating pieces

Hi,

It's my first time in git so please be patient ;-)
I'm using node-torrent lib and in node v0.8.* it was working ok but when I updated to v0.10.1 it's stops validating pieces.
I'm adding torrent and full file and I always get "Number of valid pieces = 0 out of a total of x". I was creating torrent i uTorrent and ctorrent. No luck.

Thanks for Help.
Piotr Balas

EMFILE issues (too many files open) on Mac OS

[2015-10-05 13:35:15.305] [WARN] tracker.js - announce error from udp://tracker.istole.it:80/announce: bind EMFILE
[2015-10-05 13:35:15.305] [WARN] tracker.js - retry announce 'started' in 5s

It looks like it is a OS specific issue, and people seem to suggest the same solution:
http://superuser.com/questions/433746/is-there-a-fix-for-the-too-many-open-files-in-system-error-on-os-x-10-7-1

But still it does not work for everyone -me included, I still get the error-.

I have tried using graceful-js, but no luck.

Additionally, whenever I am running this sample code, my laptop becomes extremely hot and battery drains fast:

var Client = require('node-torrent');
var client = new Client({logLevel: 'DEBUG'});
var torrent = client.addTorrent('a.torrent');

// when the torrent completes, move it's files to another area
torrent.on('complete', function() {
    console.log('complete!');
    torrent.files.forEach(function(file) {
        var newPath = '/new/path/' + file.path;
        fs.rename(file.path, newPath);
        // while still seeding need to make sure file.path points to the right place
        file.path = newPath;
    });
});

Has anyone used this library successfully on Mac OS? Is there a solution for the EMFILE error?

Syntax Error in version 0.1.6

Hi. I get version 0.1.6 via npm.
It seems contain syntax error, but fortunately it is really minor issue.
In node-torrent\lib\piece.js line 180; it should be

 self.complete = new BitField(self, self.complete.length);
 self.requested = new BitField(self, self.complete.length);

:D

Peer doesn't seed if torrent data is complete?

Instances of node-torrent on multiple machines will happily share partial torrent data, but if an instance already has a complete copy of the files, it seems it won't participate as a seed unless the 'ready' event is emitted:

torrent.js, parse()

LOGGER.info('torrent already complete');
self.emit('ready');

Unrecognized client. Please use a valid BitTorrent client.

I'm getting this error when trying to download from a popular torrent site:

Unrecognized client. Please use a valid BitTorrent client.

I tried passing in an ID of a known torrent client like this:

var client = new Client({ logLevel: 'DEBUG', id: '-UT1610-'});

But haven't had much luck. Has anyone else seen this?

complete is not defined

I use nodejs windows and return an error:

E:\node\torrent\node_modules\node-torrent\lib\piece.js:181
self.complete = new BitField(self,complete.length);
^
ReferenceError: complete is not defined

Get progress?

Hello, Im pretty new to programming with node and I was wondering if this module supports progress reports - like % downloaded

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.