@@ 18-73 (lines=56) @@ | ||
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 | /** |
|
65 | * Set Music info property |
|
66 | * |
|
67 | * @param MusicInfo $musicInfo |
|
68 | */ |
|
69 | public function setMusicInfo(MusicInfo $musicInfo) |
|
70 | { |
|
71 | $this->musicInfo = $musicInfo; |
|
72 | } |
|
73 | } |
|
74 |
@@ 18-68 (lines=51) @@ | ||
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 | /** |
|
60 | * Set Music info property |
|
61 | * |
|
62 | * @param MusicInfo $musicInfo |
|
63 | */ |
|
64 | public function setMusicInfo(MusicInfo $musicInfo) |
|
65 | { |
|
66 | $this->musicInfo = $musicInfo; |
|
67 | } |
|
68 | } |
|
69 |