| @@ 18-63 (lines=46) @@ | ||
| 15 | use Symfony\Component\Console\Input\InputInterface; |
|
| 16 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 17 | ||
| 18 | class SearchArtistCommand extends BaseCommand |
|
| 19 | { |
|
| 20 | const COMMAND_NAME = 'search:artist'; |
|
| 21 | ||
| 22 | const COMMAND_DESCRIPTION = 'Search an artist on one or more services'; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var MusicInfo |
|
| 26 | */ |
|
| 27 | protected $musicInfo; |
|
| 28 | ||
| 29 | protected function configure() |
|
| 30 | { |
|
| 31 | $this |
|
| 32 | ->addArgument('artist', InputArgument::REQUIRED, 'Artist Name') |
|
| 33 | ->addArgument('service', InputArgument::OPTIONAL, 'Service to use, default to all enabled', null); |
|
| 34 | ||
| 35 | parent::configure(); |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @param InputInterface $input |
|
| 40 | * @param OutputInterface $output |
|
| 41 | * |
|
| 42 | * @return void |
|
| 43 | */ |
|
| 44 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 45 | { |
|
| 46 | $service = ($input->getArgument('service') != '') ? $input->getArgument('service') : null; |
|
| 47 | ||
| 48 | $searchResults = $this->musicInfo->doSearch($input->getArgument('artist'), 'artist', $service); |
|
| 49 | ||
| 50 | $resultsTable = $this->generateTableForSearchResult( |
|
| 51 | $searchResults, [ |
|
| 52 | 'id' => 'ID', |
|
| 53 | 'name' => 'Name', |
|
| 54 | 'image' => 'Image URL', |
|
| 55 | 'type' => 'Type', |
|
| 56 | 'dataSource' => 'Source', |
|
| 57 | 'uri' => 'URL' |
|
| 58 | ], new Table($output) |
|
| 59 | ); |
|
| 60 | ||
| 61 | $resultsTable->render(); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| @@ 18-58 (lines=41) @@ | ||
| 15 | use Symfony\Component\Console\Input\InputInterface; |
|
| 16 | use Symfony\Component\Console\Output\OutputInterface; |
|
| 17 | ||
| 18 | class SearchTrackCommand extends BaseCommand |
|
| 19 | { |
|
| 20 | const COMMAND_NAME = 'search:track'; |
|
| 21 | ||
| 22 | const COMMAND_DESCRIPTION = 'Search a track on one or more services'; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @var MusicInfo |
|
| 26 | */ |
|
| 27 | protected $musicInfo; |
|
| 28 | ||
| 29 | protected function configure() |
|
| 30 | { |
|
| 31 | $this |
|
| 32 | ->addArgument('track', InputArgument::REQUIRED, 'Artist Name') |
|
| 33 | ->addArgument('service', InputArgument::OPTIONAL, 'Service to use, default to all enabled'); |
|
| 34 | ||
| 35 | parent::configure(); // TODO: Change the autogenerated stub |
|
| 36 | } |
|
| 37 | ||
| 38 | public function execute(InputInterface $input, OutputInterface $output) |
|
| 39 | { |
|
| 40 | $service = ($input->getArgument('service') != '') ? $input->getArgument('service') : null; |
|
| 41 | ||
| 42 | $searchResults = $this->musicInfo->doSearch($input->getArgument('track'), 'track', $service); |
|
| 43 | ||
| 44 | $resultsTable = $this->generateTableForSearchResult( |
|
| 45 | $searchResults, [ |
|
| 46 | 'id' => 'ID', |
|
| 47 | 'name' => 'Name', |
|
| 48 | 'image' => 'Image URL', |
|
| 49 | 'length'=> 'Duration', |
|
| 50 | 'type' => 'Type', |
|
| 51 | 'dataSource' => 'Source', |
|
| 52 | 'uri' => 'URL' |
|
| 53 | ], new Table($output) |
|
| 54 | ); |
|
| 55 | ||
| 56 | $resultsTable->render(); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||