How to use the torrent-search-api.enableProvider function in torrent-search-api

To help you get started, we’ve selected a few torrent-search-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fabiospampinato / cliflix / src / index.ts View on Github external
provider = await prompt.list ( 'Which torrents provider?', providers );

    }

    const categories = {
      ThePirateBay: 'Video',
      TorrentProject: 'Video'
    };

    const category = categories[provider] || 'All',
          spinner = ora ( `Waiting for "${chalk.bold ( provider )}"...` ).start ();

    try {

      torrentSearch.disableAllProviders ();
      torrentSearch.enableProvider ( provider );

      const torrents = await torrentSearch.search ( query, category, rows );

      spinner.stop ();

      if ( !torrents.length ) throw new Error ( 'No torrents found.' );

      return torrents;

    } catch ( e ) {

      spinner.stop ();

      console.error ( chalk.yellow ( `No torrents found via "${chalk.bold ( provider )}"` ) );

      const nextProviders = _.without ( providers, provider ),
github fabiospampinato / cliflix / dist / index.js View on Github external
hasProvider = !!provider;
                        if (!!provider) return [3 /*break*/, 2];
                        return [4 /*yield*/, inquirer_helpers_1.default.list('Which torrents provider?', providers)];
                    case 1:
                        provider = _a.sent();
                        _a.label = 2;
                    case 2:
                        categories = {
                            ThePirateBay: 'Video',
                            TorrentProject: 'Video'
                        }, category = categories[provider] || 'All';
                        _a.label = 3;
                    case 3:
                        _a.trys.push([3, 5, , 7]);
                        torrentSearch.disableAllProviders();
                        torrentSearch.enableProvider(provider);
                        return [4 /*yield*/, torrentSearch.search(query, category, rows)];
                    case 4:
                        torrents = _a.sent();
                        if (!torrents.length)
                            throw new Error('No torrents found.');
                        return [2 /*return*/, torrents];
                    case 5:
                        e_2 = _a.sent();
                        console.error(chalk_1.default.yellow("No torrents found via \"" + chalk_1.default.bold(provider) + "\""));
                        nextProviders = _.without(providers, provider), nextProvider = hasProvider ? providers[providers.indexOf(provider) + 1] : '';
                        if (!nextProvider && !nextProviders.length)
                            return [2 /*return*/, []];
                        return [4 /*yield*/, CLIFlix.getTorrents(query, rows, nextProvider, nextProviders)];
                    case 6: return [2 /*return*/, _a.sent()];
                    case 7: return [2 /*return*/];
                }

torrent-search-api

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

MIT
Latest version published 3 years ago

Package Health Score

42 / 100
Full package analysis