forked from deblan/t411-console
Commands to search movies or series
This commit is contained in:
parent
cfd9fef29c
commit
08eae0fa58
50
src/Console/Command/TorrentsSearchMoviesCommand.php
Normal file
50
src/Console/Command/TorrentsSearchMoviesCommand.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Console\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
|
|
||||||
|
class TorrentsSearchMoviesCommand extends Command
|
||||||
|
{
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('torrents:search:movies')
|
||||||
|
->setDescription('Search movies')
|
||||||
|
->addArgument('query', InputArgument::REQUIRED, 'Query')
|
||||||
|
->addOption('offset', 'o', InputOption::VALUE_REQUIRED, 'Page number')
|
||||||
|
->addOption('limit', 'l', InputOption::VALUE_REQUIRED, 'Number of results per page')
|
||||||
|
->addOption('terms', 't', InputOption::VALUE_REQUIRED, 'Filter by terms IDs (separated by ",")')
|
||||||
|
->setHelp("<info>%command.name%</info>
|
||||||
|
|
||||||
|
Search movies.
|
||||||
|
|
||||||
|
Usage: <comment>torrents:search:movies</comment> <info>QUERY</info> [OPTIONS]
|
||||||
|
|
||||||
|
<error>--terms does not work (API bug)</error>");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$inputData = array(
|
||||||
|
'command' => 'torrents:search',
|
||||||
|
'query' => $input->getArgument('query'),
|
||||||
|
'--sub-category' => 631,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach (['offset', 'limit', 'terms'] as $p) {
|
||||||
|
$value = $input->getOption($p);
|
||||||
|
|
||||||
|
if (null !== $value) {
|
||||||
|
$inputData['--'.$p] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getApplication()->doRun(new ArrayInput($inputData), $output);
|
||||||
|
}
|
||||||
|
}
|
50
src/Console/Command/TorrentsSearchSeriesCommand.php
Normal file
50
src/Console/Command/TorrentsSearchSeriesCommand.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Console\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
|
|
||||||
|
class TorrentsSearchSeriesCommand extends Command
|
||||||
|
{
|
||||||
|
protected function configure()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->setName('torrents:search:series')
|
||||||
|
->setDescription('Search series')
|
||||||
|
->addArgument('query', InputArgument::REQUIRED, 'Query')
|
||||||
|
->addOption('offset', 'o', InputOption::VALUE_REQUIRED, 'Page number')
|
||||||
|
->addOption('limit', 'l', InputOption::VALUE_REQUIRED, 'Number of results per page')
|
||||||
|
->addOption('terms', 't', InputOption::VALUE_REQUIRED, 'Filter by terms IDs (separated by ",")')
|
||||||
|
->setHelp("<info>%command.name%</info>
|
||||||
|
|
||||||
|
Search series.
|
||||||
|
|
||||||
|
Usage: <comment>torrents:search:series</comment> <info>QUERY</info> [OPTIONS]
|
||||||
|
|
||||||
|
<error>--terms does not work (API bug)</error>");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$inputData = array(
|
||||||
|
'command' => 'torrents:search',
|
||||||
|
'query' => $input->getArgument('query'),
|
||||||
|
'--sub-category' => 433,
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach (['offset', 'limit', 'terms'] as $p) {
|
||||||
|
$value = $input->getOption($p);
|
||||||
|
|
||||||
|
if (null !== $value) {
|
||||||
|
$inputData['--'.$p] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->getApplication()->doRun(new ArrayInput($inputData), $output);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue