TorrentSearchApi
![npm](https://img.shields.io/npm/dm/torrent-search-api.svg?maxAge=2592000)
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');
const torrents = await TorrentSearchApi.search('1080', 'Movies', 20);
Torrent Search API
Get providers
const providers = TorrentSearchApi.getProviders();
const activeProviders = TorrentSearchApi.getActiveProviders();
{
{
name: 'Torrent9',
public: true,
categories: ['All', 'Movies', 'TV', 'Music', 'Apps', 'Books', 'Top100']
},
{
name: 'IpTorrents',
public: false,
categories: ['All', 'Movies', 'TV', 'Games', 'Music']
},
...
}
Enable provider
TorrentSearchApi.enablePublicProviders();
TorrentSearchApi.enableProvider('Torrent9');
TorrentSearchApi.enableProvider('IpTorrents', ['uid=XXX;', 'pass=XXX;']);
TorrentSearchApi.enableProvider('IpTorrents', 'USERNAME', 'PASSWORD');
TorrentSearchApi.enableProvider('xxx', 'TOKEN');
Disable provider
TorrentSearchApi.disableProvider('TorrentLeech');
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.
const torrents = await TorrentSearchApi.search('1080', 'Movies', 20);
const torrents = await TorrentSearchApi.search(['IpTorrents', 'Torrent9'], '1080', 'Movies', 20);
Torrent details
const torrentHtmlDetail = await TorrentSearchApi.getTorrentDetails(torrent);
Torrent magnet
const magnet = await TorrentSearchApi.getMagnet(torrent);
Download torrent
const buffer = await TorrentSearchApi.downloadTorrent(torrent);
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.
const MyCustomProvider = require('./MyCustomProvider');
TorrentSearchApi.loadProvider(MyCustomProvider);
TorrentSearchApi.loadProvider( {});
const path = require('path');
const providerFullPath = path.join(__dirname, './lib/providers/MyCustomProvider');
TorrentSearchApi.loadProviders(providerFullPath);
const path = require('path');
const providerDirFullPath = path.join(__dirname, './lib/providers/');
TorrentSearchApi.loadProviders(providerDirFullPath);
const MyCustomProvider = require('./MyCustomProvider');
TorrentSearchApi.loadProviders(MyCustomProvider, {}, ...);
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
const createApi = require('torrent-search-api/createApi');
const TorrentSearchApi = createApi()
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
TorrentSearchApi.overrideConfig(providerName, newConfig);
License
MIT © 2020 Jimmy Laurent