✨ Export films
This commit is contained in:
parent
1295b03c3a
commit
dfc11d7a7f
5 changed files with 71 additions and 14 deletions
|
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Data\DataPipes;
|
||||
|
||||
use App\Data\Enums\Type;
|
||||
use App\Data\FileData;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
|
@ -18,12 +21,19 @@ class ParseWatchFile implements DataPipe
|
|||
public function handle(mixed $payload, DataClass $class, Collection $properties): Collection
|
||||
{
|
||||
$properties['watched'] = Carbon::now();
|
||||
$properties['output'] = sprintf(
|
||||
'%s-%dx%02d.json',
|
||||
Str::slug($properties['showTitle'] ?? uniqid()),
|
||||
$properties['season'],
|
||||
$properties['episode']
|
||||
);
|
||||
$properties['output'] = match ($properties['type']) {
|
||||
Type::Movie => sprintf(
|
||||
'%s-%d.json',
|
||||
Str::slug($properties['showTitle'] ?? uniqid()),
|
||||
$properties['movieYear'],
|
||||
),
|
||||
default => sprintf(
|
||||
'%s-%dx%02d.json',
|
||||
Str::slug($properties['showTitle'] ?? uniqid()),
|
||||
$properties['season'],
|
||||
$properties['episode']
|
||||
),
|
||||
};
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue