Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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*/];
}
});
}
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 ),
nextProvider = hasProvider ? providers[providers.indexOf ( provider ) + 1] : '';