Add current tiem to output filename

This commit is contained in:
Dan Jones 2025-10-27 08:54:39 -05:00
commit 5fd2fd103e

View file

@ -20,18 +20,21 @@ class ParseWatchFile implements DataPipe
{ {
public function handle(mixed $payload, DataClass $class, Collection $properties): Collection public function handle(mixed $payload, DataClass $class, Collection $properties): Collection
{ {
$n = now()->format('U');
$properties['watched'] = Carbon::now(); $properties['watched'] = Carbon::now();
$properties['output'] = match ($properties['type']) { $properties['output'] = match ($properties['type']) {
Type::Movie => sprintf( Type::Movie => sprintf(
'%s-%d.json', '%s-%d-%s.json',
Str::slug($properties['showTitle'] ?? uniqid()), Str::slug($properties['showTitle'] ?? uniqid()),
$properties['movieYear'], $properties['movieYear'],
$n,
), ),
default => sprintf( default => sprintf(
'%s-%dx%02d.json', '%s-%dx%02d-%s.json',
Str::slug($properties['showTitle'] ?? uniqid()), Str::slug($properties['showTitle'] ?? uniqid()),
$properties['season'], $properties['season'],
$properties['episode'] $properties['episode'],
$n,
), ),
}; };