npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

torrents-search

v2.0.6

Published

Search torrents on private and public trackers websites

Downloads

64

Readme

node-torrents-search

NPM David DM

Node module used to search torrents on private trackers websites.

Currently supported trackers

  • 1337x
  • Torrent9
  • TorrentLeech
  • ~~Cpasbien~~
  • ~~t411~~
  • ~~FrenchTorrentDB~~

You can easily add new trackers by creating a file in lib/trackers.

Install

npm install torrents-search

Usage

const TorrentsSearch = require('..');
const extend = require('extend');

// Custom logger
const myLogger = {
  info: function(msg) {
    console.log(msg);
  },

  error: function(msg) {
    console.error(msg);
  }
};

const search = new TorrentsSearch({
  logger: myLogger, // Optional
  timeout: 100000 // Optional
});

search.loadTrackers()
  .then(() => {
    // Display all loaded trackers
    console.log('Loaded trackers :', search.getTrackers());

    // Enable trackers
    search.enableTracker('Torrent9');
    search.enableTracker('1337x');

    search.enableTracker('TorrentLeech');
    search.setCredentials('TorrentLeech', 'USERNAME', 'PASSWORD');
  })
  .then(() => {
    // Search torrents on all enabled trackers
    return search.search('SEARCH_QUERY', {type: 'movies'});
  })
  .then((torrents) => {
    console.log(torrents.length +' torrent(s) found.');

    if(torrents.length === 0) {
      return null;
    }

    torrents.forEach((torrent) => {
      const t = extend(true, {}, torrent);
      delete t._tracker;

      console.log(t);
    });

    console.log('Downloading first torrent ('+ torrents[0].name +' from '+ torrents[0].tracker +') :');
    return search.download(torrents[0]);
  })
  .then((torrentFileBuffer) => {
    if(torrentFileBuffer) {
      console.log(torrentFileBuffer);
    }
  }).catch((reason) => {
    console.error('An error occured:');
    console.error(reason);
  });

Options

  • logger This let you define a custom logger. It should have two methods : info and error. If you just want to log errors, just create an empty info method. Default is an empty logger that will do nothing.
  • timeout Define the desired timeout (milliseconds) for requests sent to trackers. Default is 10000 (10s). This is a way to protect us from slow trackers who can block others.

Events

  • on('trackers:loaded', function(trackers) {})

    When trackers are loaded.

  • on('tracker:enabled', function(tracker) {})

    When a tracker is enabled.

  • on('tracker:disabled', function(tracker) {})

    When a tracker is disabled.

  • on('tracker:loginSuccess', function(tracker) {})

    When a login is successfull on a tracker.

  • on('tracker:torrentsFound', function(torrents, tracker) {})

    When torrents are found on a tracker.

  • on('tracker:torrentsSearchError', function(error, tracker) {})

    When an error occurs during torrents search on a tracker.

  • on('tracker:torrentsSearchError', function(error, tracker) {})

    When an error occurs during torrents search on a tracker.

API

Here is the list of all available methods of the module.

  • loadTrackers()

    Load all the trackers in the lib/trackers folder. You need to call this before calling any other method. All trackers loaded are disabled by default if they need authentification, or enabled if not.

    It returns a promise.

  • getTrackers()

    Return an object { enabled: [], disabled: [] } with the names of the loaded trackers.

  • enableTracker(trackerName)

    Enable the specified tracker.

    Returns a boolean indicating if the operation succeeded or not.

  • disableTracker(trackerName)

    Disable the specified tracker.

    Returns a boolean indicating if the operation succeeded or not.

  • setCredentials(trackerName, username, password)

    Set the username/password used for the tracker.

  • login()

    Login on all enabled trackers. This is automatically done when using a method requiring login (search, download).

    It returns a promise.

  • search(query, options, callback)

    Search the specified query on all enabled trackers.

    Options is an object with the following properties :

    • type : movie or tvshow

    It returns a promise with an array of Torrent objects if resolved.

  • download(torrent, callback)

    Download the specified .torrent.

    It returns a promise with an the file buffer of the .torrent if resolved.

TODO

  • [ ] Add tests
  • [ ] Use x-rax
  • [ ] Use string-format
  • Add more trackers
    • [x] Torrent9
    • [x] 1337x
    • [x] torrentleech
    • [ ] katcr.co/new
    • [ ] torrentproject
    • [ ] iptorrents

Changelog

v2.0.5

  • [x] Fix "regex" x-ray filter to get IDs of Torrent9 & 1337x torrents

v2.0.3

  • [x] Fix typo

v2.0.2

  • [x] Bugfixes

v2.0.1

  • [x] Add TorrentLeech tracker

v2.0.0

  • [x] Refactor Tracker class to use x-rax
  • [x] Remove Babel
  • [x] Switch to yarn
  • [x] Cleanup
  • [x] Remove t411 tracker
  • [x] Remove Cpasbien tracker
  • [x] Add 1337x tracker
  • [x] Add Torrent9 tracker

v1.1.0

  • [x] Size of torrents in bytes

v1.0.4

  • [x] Update depencencies
  • [x] Remove FrenchTorrentDB (dead)
  • [x] Update Cpasbien domain

Licence

(The MIT License)

Copyright (C) 2013 Leeroy Brun, www.leeroy.me

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.