Leite Vorschaubilder und Filmstufen geschuetzt ab
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d6ff881e4e
commit
c997eb500c
32 files changed
+979
-68
No files matched your search
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Media\FilmTranscoder;
|
||||
use App\Domain\Media\MediaRendition;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
use Throwable;
|
||||
|
||||
class DeriveFilmRenditions implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public int $timeout = 3600;
|
||||
|
||||
public function __construct(public readonly int $versionId) {}
|
||||
|
||||
public function handle(FilmTranscoder $transcoder): void
|
||||
{
|
||||
$version = ContentElementVersion::query()->with('element')->find($this->versionId);
|
||||
$file = is_array($version?->metadata) ? ($version->metadata['file'] ?? null) : null;
|
||||
|
||||
if ($version === null || $version->element->output_class !== 'film' || ! is_string($file) || $file === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $transcoder->available()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$rows = $transcoder->derive($version->id, $file);
|
||||
} catch (Throwable) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($rows as $row) {
|
||||
MediaRendition::query()->updateOrCreate(
|
||||
[
|
||||
'content_element_version_id' => $version->id,
|
||||
'label' => $row['label'],
|
||||
],
|
||||
[
|
||||
'role' => $row['role'],
|
||||
'path' => $row['path'],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user