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

torrent-search-api

v2.1.4

Published

Yet another node torrent scraper based on x-ray. (Support iptorrents, torrentleech, torrent9, Yyggtorrent, ThePiratebay, torrentz2, 1337x, KickassTorrent, Rarbg, TorrentProject, Yts, Limetorrents, Eztv)

Downloads

1,398

Readme

TorrentSearchApi

npm

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
  • Yts
  • Limetorrents
  • Eztv

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');

TorrentSearchApi.enableProvider('Torrent9');

// Search '1080' in 'Movies' category and limit to 20 results
const torrents = await TorrentSearchApi.search('1080', 'Movies', 20);

Torrent Search API

Get providers

// Get providers
const providers = TorrentSearchApi.getProviders();

// Get active providers
const activeProviders = TorrentSearchApi.getActiveProviders();

// providers
{
    {
        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 providers
TorrentSearchApi.enablePublicProviders();

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

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

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

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

Disable provider


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

// Disable all enabled providers
TorrentSearchApi.disableAllProviders();

Check if a provider exists and is active


TorrentSearchApi.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)
const torrents = await TorrentSearchApi.search('1080', 'Movies', 20);

// Search with given providers
// query: 1080
// category: Movies (optional)
// limit: 20 (optional)
const torrents = await TorrentSearchApi.search(['IpTorrents', 'Torrent9'], '1080', 'Movies', 20);

Torrent details


// Get details (raw scraped html)
// torrent: taken from a search result
const torrentHtmlDetail = await TorrentSearchApi.getTorrentDetails(torrent);

Torrent magnet


// Get magnet url
// torrent: taken from a search result
const magnet = await TorrentSearchApi.getMagnet(torrent);

Download torrent


// Download a buffer
// torrent: taken from a search result
const buffer = await TorrentSearchApi.downloadTorrent(torrent);

// Download torrent and write it to the disk
// torrent: taken from a search result
await TorrentSearchApi.downloadTorrent(torrent, filnamePath);

Load custom providers

You can code and add your custom providers (see provider definition format in existing providers) Don't forget to enable your provider if you intend to use it.


// load multipe providers
// from a TorrentProvider custom class definition or instance
const MyCustomProvider = require('./MyCustomProvider');
TorrentSearchApi.loadProvider(MyCustomProvider);

// from a provider object definition
TorrentSearchApi.loadProvider( {/* provider object definition */});

// from an absolute path to class definition or json object definition
const path = require('path');
const providerFullPath = path.join(__dirname, './lib/providers/MyCustomProvider');
TorrentSearchApi.loadProviders(providerFullPath);

// load multipe providers within a directory
// only absolute path are allowed
// it loads every *.json and *.js file
const path = require('path');
const providerDirFullPath = path.join(__dirname, './lib/providers/');
TorrentSearchApi.loadProviders(providerDirFullPath);

// load multipe providers
const MyCustomProvider = require('./MyCustomProvider');
TorrentSearchApi.loadProviders(MyCustomProvider, {/* provider object definition */}, ...);

Remove provider


// Remove provider
TorrentSearchApi.removeProvider('MyCustomProvider');

Create TorrentSearchApi instance

If you want to create an instance of the api without loading all the default providers and only load the ones that you want


// create instance
const createApi = require('torrent-search-api/createApi');
const TorrentSearchApi = createApi(/* same arguments as "loadProviders" method */)

Create a new provider

Check "test/createProvider.test.js" file if you want to create a new provider.

Running tests command

npm run test:watch

Override provider config

// Fully or partial override of the provider config
TorrentSearchApi.overrideConfig(providerName, newConfig);

License

MIT © 2020 Jimmy Laurent