GithubHelp home page GithubHelp logo

t411's Introduction

t411

T411 API client

A client for the T411 API that works both in node and the browser with browserify.

Install

$ npm install t411

Usage

var T411 = require('t411');

var client = new T411();

client.auth('your-username', 'your-password', function(err) {
  if(err) throw err;

  // search torrents
  client.search('interstellar', function(err, result) {
    if(err) throw err;
    console.log(result);
  });

  // download and parse a .torrent
  client.download(id, function(err, buf) {
    // `buf` is a Buffer in node as well as in the browser
    var parsed = require('parse-torrent')(buf);
    console.log(parsed);
  });

  // All the methods provided by the API are implemented (categories,
  // terms, tops, bookmarks). For advanced use check the source code, 
  // it should be pretty easy to read :)
});

t411's People

Contributors

bricejulia avatar endless22 avatar kilhog avatar lludol avatar meriadec avatar micdu70 avatar thibauts avatar ylon avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

t411's Issues

Error while authenticating

Hi !

When I try to authenticate with your node module I get this error :

undefined
^
SyntaxError: Unexpected token u
    at Object.parse (native)
    at /var/www/node_modules/t411/index.js:197:21
    at Request.callback (/var/www/node_modules/t411/node_modules/superagent/lib/node/index.js:691:12)
    at ClientRequest.<anonymous> (/var/www/node_modules/t411/node_modules/superagent/lib/node/index.js:901:12)
    at ClientRequest.EventEmitter.emit (events.js:95:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1688:21)
    at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
    at CleartextStream.socketOnData [as ondata] (http.js:1583:20)
    at CleartextStream.read [as _read] (tls.js:511:12)
    at CleartextStream.Readable.read (_stream_readable.js:320:10)

I think it's from the index.js class at
var data = JSON.parse(res.text);
res doesn't have a 'text'

Error when I want to download a torrent node.js v6

Hello,

There is a bug with node.js v6.

I am using the same code as your example. The id of the torrent is good (I tried with postman).
With the LTS version it's OK but with the v6, it's not working.

The error:

RangeError: 'offset' is out of bounds
    at RangeError (native)
    at fromArrayBuffer (buffer.js:257:20)
    at Function.Buffer.from (buffer.js:128:12)
    at new Buffer (buffer.js:112:17)
    at typedarrayToBuffer (/home/lludol/Documents/secret-project/node_modules/typedarray-to-buffer/index.js:15:15)
    at request.parse.application/x-bittorrent (/home/lludol/Documents/secret-project/node_modules/t411/index.js:207:10)
    at ClientRequest.<anonymous> (/home/lludol/Documents/secret-project/node_modules/superagent/lib/node/index.js:883:9)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:469:21)

EDIT:
I have created a PR to fix the bug.

Node server crash when bad torrent request

Hi !

I'm here to report a bug: When doing a bad search, my node server went down.

Here's the log:

undefined:1
<div class="errorMessage">assert(): Assertion failed</div>
^
SyntaxError: Unexpected token <
    at Object.parse (native)
    at /var/www/node_modules/t411/index.js:198:21
    at Request.callback (/var/www/node_modules/t411/node_modules/superagent/lib/node/index.js:691:12)
    at Stream.<anonymous> (/var/www/node_modules/t411/node_modules/superagent/lib/node/index.js:922:12)
    at Stream.EventEmitter.emit (events.js:117:20)
    at Unzip.<anonymous> (/var/www/node_modules/t411/node_modules/superagent/lib/node/utils.js:108:12)
    at Unzip.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)

Maybe you should add a try, catch at t411/index.js line 198

Did the trick for me:

try {
    var data = JSON.parse(res.text);

    if(data.error) {
      var err = new Error(data.error);
      err.code = data.code;
      return callback(err);
    }

    callback(null, data);
  } catch (e) {
    callback("Error: " + e);
  }

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.