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
- 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 = ; TorrentSearchApi; // Search '1080' in 'Movies' category and limit to 20 resultsconst torrents = await TorrentSearchApi;
Torrent Search API
Get providers
// Get providersconst providers = TorrentSearchApi; // Get active providersconst activeProviders = TorrentSearchApi; // 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 providersTorrentSearchApi; // Enable public providerTorrentSearchApi; // Enable private provider with cookiesTorrentSearchApi; // Enable private provider with credentialsTorrentSearchApi; // Enable private provider with tokenTorrentSearchApi;
Disable provider
// Disable providerTorrentSearchApi; // Disable all enabled providersTorrentSearchApi;
Check if a provider exists and is active
TorrentSearchApi;
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 with given providers// query: 1080// category: Movies (optional)// limit: 20 (optional)const torrents = await TorrentSearchApi;
Torrent details
// Get details (raw scraped html)// torrent: taken from a search resultconst torrentHtmlDetail = await TorrentSearchApi;
Torrent magnet
// Get magnet url// torrent: taken from a search resultconst magnet = await TorrentSearchApi;
Download torrent
// Download a buffer// torrent: taken from a search resultconst buffer = await TorrentSearchApi; // Download torrent and write it to the disk// torrent: taken from a search resultawait TorrentSearchApi;
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 instanceconst MyCustomProvider = ;TorrentSearchApi; // from a provider object definitionTorrentSearchApi; // from an absolute path to class definition or json object definitionconst path = ;const providerFullPath = path;TorrentSearchApi; // load multipe providers within a directory// only absolute path are allowed// it loads every *.json and *.js fileconst path = ;const providerDirFullPath = path;TorrentSearchApi; // load multipe providersconst MyCustomProvider = ;TorrentSearchApi;
Remove provider
// Remove providerTorrentSearchApi;
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 instanceconst createApi = ;const TorrentSearchApi =
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 configTorrentSearchApi;
License
MIT © 2020 Jimmy Laurent