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'],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Domain\Catalog\Composition;
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Media\ThumbnailDeriver;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Queue\Queueable;
|
||||
|
||||
class DeriveThumbnail implements ShouldQueue
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public function __construct(
|
||||
public readonly string $subject,
|
||||
public readonly int $subjectId,
|
||||
public readonly ?string $incoming = null,
|
||||
) {}
|
||||
|
||||
public function handle(ThumbnailDeriver $deriver): void
|
||||
{
|
||||
if ($this->subject === 'komposition') {
|
||||
$composition = Composition::query()->find($this->subjectId);
|
||||
|
||||
if ($composition !== null && is_string($this->incoming)) {
|
||||
$deriver->forCompositionUpload($composition, $this->incoming);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$element = ContentElement::query()->find($this->subjectId);
|
||||
|
||||
if ($element !== null) {
|
||||
$deriver->forElement($element);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,6 +72,8 @@ public function handle(): void
|
||||
], JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
|
||||
$version->status = ContentVersionStatus::Bereit;
|
||||
$version->save();
|
||||
DeriveThumbnail::dispatch('element', $version->content_element_id);
|
||||
DeriveFilmRenditions::dispatch($version->id);
|
||||
}
|
||||
|
||||
private function storedName(string $name): ?string
|
||||
|
||||
Reference in new issue
Block a user