diff --git a/app/Commands/GetShow.php b/app/Commands/GetShow.php index 5686899..864f2b4 100644 --- a/app/Commands/GetShow.php +++ b/app/Commands/GetShow.php @@ -20,12 +20,12 @@ class GetShow extends Command protected $description = 'Queue a show to re-encode or download'; - public function handle(): int + public function handle(ProcessInput $proc): int { $this->line('Options: ' . json_encode($this->options()), verbosity: OutputInterface::VERBOSITY_DEBUG); $input = $this->getInput(); $this->line('Input: ' . json_encode($input), verbosity: OutputInterface::VERBOSITY_DEBUG); - $job = app()->make(ProcessInput::class)->getJob($input); + $job = $proc->getJob($input); $this->line('Job: ' . json_encode($job), verbosity: OutputInterface::VERBOSITY_DEBUG); return static::SUCCESS; diff --git a/app/Data/DataPipes/ExtraFiles.php b/app/Data/DataPipes/ExtraFiles.php new file mode 100644 index 0000000..9f25c5b --- /dev/null +++ b/app/Data/DataPipes/ExtraFiles.php @@ -0,0 +1,36 @@ +has('files') || !$properties->get('files')->count()) { + return $properties; + } + + $files = $properties->get('files'); + $col = $files->toCollection(); + foreach ($files->items() as $file) { + $pi = pathinfo($file->path); + foreach (glob($pi['dirname'].'/'.$pi['filename'].'*') as $path) { + if (!$col->first(fn (FileData $data) => $data->path === $path)) { + $files[] = $path; + } + } + } + $properties['files'] = $files; + + return $properties; + } +} diff --git a/app/Data/InputData.php b/app/Data/InputData.php index b162ca8..bfb2c00 100644 --- a/app/Data/InputData.php +++ b/app/Data/InputData.php @@ -7,6 +7,7 @@ use Spatie\LaravelData\Attributes\DataCollectionOf; use Spatie\LaravelData\Attributes\MapInputName; use Spatie\LaravelData\DataCollection; use Spatie\LaravelData\Attributes\WithCast; +use Spatie\LaravelData\DataPipeline; class InputData extends Data { @@ -40,4 +41,14 @@ class InputData extends Data { return !empty($this->files) && !!$this->files->count(); } + + public static function pipeline(): DataPipeline + { + return parent::pipeline()->through(DataPipes\ExtraFiles::class); + } + + public static function fillPipeline(): DataPipeline + { + return parent::fillPipeline()->through(DataPipes\ExtraFiles::class); + } }