| 
									
										
										
										
											2022-03-03 22:55:57 -06:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace App\Commands; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | use App\Exceptions\Quit; | 
					
						
							| 
									
										
										
										
											2022-03-05 19:51:04 -06:00
										 |  |  | use App\Models\Input; | 
					
						
							| 
									
										
										
										
											2022-03-25 17:02:09 -05:00
										 |  |  | use App\Services\ProcessInput; | 
					
						
							|  |  |  | use Symfony\Component\Console\Output\OutputInterface; | 
					
						
							| 
									
										
										
										
											2022-03-03 22:55:57 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  | class GetShow extends Command | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     protected $signature = 'get:show ' . | 
					
						
							|  |  |  |                          '{--i|input=* : Input files} ' . | 
					
						
							| 
									
										
										
										
											2022-03-05 19:51:04 -06:00
										 |  |  |                          '{--u|url= : URL to download} ' . | 
					
						
							| 
									
										
										
										
											2022-03-03 22:55:57 -06:00
										 |  |  |                          '{--d|destination= : Directory of show} ' . | 
					
						
							|  |  |  |                          '{--t|title= : The title of the episode} ' . | 
					
						
							|  |  |  |                          '{--l|low : Put on low priority queue}' . | 
					
						
							|  |  |  |                          '{--s|sync : Run synchronously}' | 
					
						
							|  |  |  |                          ; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     protected $description = 'Queue a show to re-encode or download'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function handle(): int | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-25 17:02:09 -05:00
										 |  |  |         $this->line('Options: ' . json_encode($this->options()), verbosity: OutputInterface::VERBOSITY_DEBUG); | 
					
						
							| 
									
										
										
										
											2022-03-05 19:51:04 -06:00
										 |  |  |         $input = $this->getInput(); | 
					
						
							| 
									
										
										
										
											2022-03-25 17:02:09 -05:00
										 |  |  |         $this->line('Input: ' . json_encode($input), verbosity: OutputInterface::VERBOSITY_DEBUG); | 
					
						
							|  |  |  |         $job = app()->make(ProcessInput::class)->getJob($input); | 
					
						
							|  |  |  |         $this->line('Job: ' . json_encode($job), verbosity: OutputInterface::VERBOSITY_DEBUG); | 
					
						
							| 
									
										
										
										
											2022-03-03 22:55:57 -06:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return static::SUCCESS; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-05 19:51:04 -06:00
										 |  |  |     protected function getInput(): Input | 
					
						
							| 
									
										
										
										
											2022-03-03 22:55:57 -06:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2022-03-25 17:02:09 -05:00
										 |  |  |         return (new Input($this->options()))->assertValid(); | 
					
						
							| 
									
										
										
										
											2022-03-03 22:55:57 -06:00
										 |  |  |     } | 
					
						
							|  |  |  | } |