49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Commands;
|
|
|
|
use App\Exceptions\Quit;
|
|
|
|
class GetShow extends Command
|
|
{
|
|
protected $signature = 'get:show ' .
|
|
'{--i|input=* : Input files} ' .
|
|
'{--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
|
|
{
|
|
$this->line(json_encode($this->options()));
|
|
# $this->ask('What?');
|
|
# throw new Quit('Nope', 5);
|
|
$files = $this->getFiles();
|
|
if ($this->confirm('Do you wish to continue?', true)) {
|
|
$this->line(json_encode($files));
|
|
}
|
|
|
|
return static::SUCCESS;
|
|
}
|
|
|
|
protected function getFiles(): array
|
|
{
|
|
$input = $this->option('input');
|
|
if (empty($input)) {
|
|
throw new Quit('No files given');
|
|
}
|
|
|
|
$files = array_map(function (string $file) {
|
|
if (!file_exists($file)) {
|
|
throw new Quit("$file is not a valid file");
|
|
}
|
|
|
|
return realpath($file);
|
|
}, $input);
|
|
|
|
return $files;
|
|
}
|
|
}
|