Code Monkey home page Code Monkey logo

torrent-search-api's Introduction

TorrentSearchApi

Yet another node torrent search api based on x-ray.

Install

npm install torrent-search-api

Supported providers

  • TorrentLeech: cookie authentification
  • IpTorrents: credentials and cookie authentification
  • Torrent9
  • Torrentz2
  • 1337x
  • ThePirateBay
  • YggTorrent : credentials and cookie authentification
  • KickassTorrents
  • Rarbg
  • TorrentProject

Features

  • Search: search torrents on multiples providers.

  • Torrent details: get details about torrents (raw scraped html).

  • Download: download torrents files.

  • Easily extensible: you can easily add new providers and enjoy built-in features like cloudfare bypass.

Quick Example

const TorrentSearchApi = require('torrent-search-api');

const torrentSearch = new TorrentSearchApi();

torrentSearch.enableProvider('Torrent9');

// Search '1080' in 'Movies' category and limit to 20 results
torrentSearch.search('1080', 'Movies', 20)
     .then(torrents => {
         console.log(torrents);
     })
     .catch(err => {
         console.log(err);
     });

Torrent Search API

Get providers

// Get providers
console.log(torrentSearch.getProviders());

// Get active providers
console.log(torrentSearch.getActiveProviders());

// Results
{
    {
        name: 'Torrent9',
        public: true,
        categories: ['All', 'Movies', 'TV', 'Music', 'Apps', 'Books', 'Top100']
    },
    {
        name: 'IpTorrents',
        public: false,
        categories: ['All', 'Movies', 'TV', 'Games', 'Music']
    },
    ...
}

Enable provider

// Enable public provider
torrentSearch.enableProvider('Torrent9');

// Enable private provider with cookies
torrentSearch.enableProvider('IpTorrents', ['uid=XXX;', 'pass=XXX;']);

// Enable private provider with credentials
torrentSearch.enableProvider('IpTorrents', 'USERNAME', 'PASSWORD');

// Enable private provider with token
torrentSearch.enableProvider('xxx', 'TOKEN');

Disable provider

// Disable provider
torrentSearch.disableProvider('TorrentLeech');

Check if a provider exists and is active

torrentSearch.isProviderActive('1337x');

Search torrent

The result is an array of torrents sorted by seeders with more or less properties depending on the provider.

// Search on actives providers
// Query: 1080
// Category: Movies (optional)
// Limit: 20 (optional)
torrentSearch.search('1080', 'Movies', 20)
    .then(torrents => {
        console.log(torrents);
    })
    .catch(err => {
        console.log(err);
    });

// Search with given providers
// query: 1080
// category: Movies (optional)
// limit: 20 (optional)
torrentSearch.search(['IpTorrents', 'Torrent9'], '1080', 'Movies', 20)
    .then(torrents => {
        console.log(torrents);
    })
    .catch(err => {
        console.log(err);
    });

Torrent details

// Get details (raw scraped html)
// torrent: taken from a search result
torrentSearch.getTorrentDetails(torrent)
    .then(html => {
        console.log(html);
    })
    .catch(err => {
        console.log(err);
    });

Torrent magnet

// Get magnet url
// torrent: taken from a search result
torrentSearch.getMagnet(torrent)
    .then(magnet => {
        console.log(magnet);
    })
    .catch(err => {
        console.log(err);
    });

Download torrent

// Download a buffer
// torrent: taken from a search result
torrentSearch.downloadTorrent(torrent)
    .then(buffer => {
        // do something with the buffer
    })
    .catch(err => {
        console.log(err);
    });

// Download torrent and write it to the disk
// torrent: taken from a search result
torrentSearch.downloadTorrent(torrent, filnamePath)
    .then(() => {
        // OK
    })
    .catch(err => {
        console.log(err);
    });

License

MIT © 2017 Jimmy Laurent

torrent-search-api's People

Contributors

dewep avatar jimmylaurent avatar tristepin avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

anikesh-del

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.