mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
updates
This commit is contained in:
@@ -3800,6 +3800,17 @@ $collections = [
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => 'second',
|
||||
'type' => Database::VAR_INTEGER,
|
||||
'format' => '',
|
||||
'size' => 0,
|
||||
'signed' => false,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
[
|
||||
|
||||
@@ -335,7 +335,7 @@ App::post('/v1/videos/:videoId/preview')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||
->label('sdk.namespace', 'videos')
|
||||
->label('sdk.method', 'createPreview')
|
||||
->label('sdk.description', '/docs/references/videos/create.md') // TODO: Create markdown
|
||||
->label('sdk.description', '/docs/references/videos/create-preview.md') // TODO: Create markdown
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VIDEO)
|
||||
@@ -354,8 +354,7 @@ App::post('/v1/videos/:videoId/preview')
|
||||
}
|
||||
|
||||
validateFilePermissions($dbForProject, $video['bucketId'], $video['fileId'], $mode);
|
||||
var_dump($second);
|
||||
var_dump($video['duration']);
|
||||
|
||||
$range = new Range(1, ($video['duration'] / 1000), Validator::TYPE_INTEGER);
|
||||
if (!$range->isValid($second)) {
|
||||
throw new Exception(Exception::VIDEO_SECOND_OUT_OF_RANGE);
|
||||
|
||||
+8
-11
@@ -722,20 +722,9 @@ class DeletesV1 extends Worker
|
||||
protected function deleteBucket(Document $document, string $projectId)
|
||||
{
|
||||
$dbForProject = $this->getProjectDB($projectId);
|
||||
|
||||
$dbForProject->deleteCollection('bucket_' . $document->getInternalId());
|
||||
$dbForProject->deleteCollection('videos_' . $document->getInternalId());
|
||||
$dbForProject->deleteCollection('videos_' . $document->getInternalId() . '_renditions');
|
||||
$dbForProject->deleteCollection('videos_' . $document->getInternalId() . '_renditions_segments');
|
||||
$dbForProject->deleteCollection('videos_' . $document->getInternalId() . '_subtitles');
|
||||
$dbForProject->deleteCollection('videos_' . $document->getInternalId() . '_subtitles_segments');
|
||||
$dbForProject->deleteCollection('videos_' . $document->getInternalId() . '_profiles');
|
||||
|
||||
$device = $this->getFilesDevice($projectId);
|
||||
$device->deletePath($document->getId());
|
||||
|
||||
$device = $this->getVideoDevice($projectId);
|
||||
$device->deletePath($document->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -747,6 +736,14 @@ class DeletesV1 extends Worker
|
||||
|
||||
$videoId = $document->getId();
|
||||
$dbForProject = $this->getProjectDB($projectId);
|
||||
|
||||
$previews = $dbForProject->find('videos_previews', [
|
||||
new Query('videoId', Query::TYPE_EQUAL, [$videoId])
|
||||
]);
|
||||
foreach ($previews as $preview) {
|
||||
$dbForProject->deleteDocument('videos_previews', $preview->getId());
|
||||
}
|
||||
|
||||
$renditions = $dbForProject->find('videos_renditions', [
|
||||
new Query('videoId', Query::TYPE_EQUAL, [$videoId])
|
||||
]);
|
||||
|
||||
+36
-27
@@ -6,7 +6,6 @@ use Appwrite\Extend\Exception;
|
||||
use Appwrite\Messaging\Adapter\Realtime;
|
||||
use Appwrite\OpenSSL\OpenSSL;
|
||||
use Appwrite\Resque\Worker;
|
||||
use Appwrite\Utopia\Response\Model\Execution;
|
||||
use Streaming\FFMpeg;
|
||||
use FFMpeg\FFProbe;
|
||||
use Streaming\Format\StreamFormat;
|
||||
@@ -19,7 +18,6 @@ use Utopia\CLI\Console;
|
||||
use Utopia\Database\Database;
|
||||
use Utopia\Database\DateTime;
|
||||
use Utopia\Database\Document;
|
||||
use Utopia\Database\Exception\Duplicate;
|
||||
use Utopia\Database\Query;
|
||||
use Utopia\Storage\Compression\Algorithms\GZIP;
|
||||
use Utopia\Storage\Compression\Algorithms\Zstd;
|
||||
@@ -191,33 +189,42 @@ class VideosV1 extends Worker
|
||||
(new Local('/'))->read($this->outDir . $name)
|
||||
);
|
||||
|
||||
try {
|
||||
$preview = $this->database->findOne('videos_previews', [
|
||||
Query::equal('videoId', [$this->video->getId()]),
|
||||
Query::equal('type', [$this->action]),
|
||||
Query::equal('name', [$name]),
|
||||
]);
|
||||
|
||||
if (empty($preview)) {
|
||||
$preview = $this->database->createDocument('videos_previews', new Document([
|
||||
'videoId' => $this->video->getId(),
|
||||
'type' => 'preview',
|
||||
'type' => $this->action,
|
||||
'name' => $name,
|
||||
'path' => $path,
|
||||
'second' => $this->args['second'],
|
||||
]));
|
||||
} catch (Duplicate $th) {
|
||||
;
|
||||
|
||||
$this->video->setAttribute('previewId', $preview->getId());
|
||||
$this->database->updateDocument(
|
||||
'videos',
|
||||
$this->video->getId(),
|
||||
new document(
|
||||
array_filter((array)$this->video, fn ($value) => !is_null($value))
|
||||
),
|
||||
);
|
||||
} else {
|
||||
$this->database->updateDocument(
|
||||
'videos_previews',
|
||||
$preview->getId(),
|
||||
$preview->setAttribute('second', $this->args['second'])
|
||||
);
|
||||
|
||||
(new Delete())
|
||||
->setType(DELETE_TYPE_CACHE_BY_RESOURCE)
|
||||
->setResource('preview/' . $preview->getId())
|
||||
->trigger();
|
||||
}
|
||||
|
||||
$this->video->setAttribute('previewId', $preview->getId());
|
||||
|
||||
(new Delete())
|
||||
->setType(DELETE_TYPE_CACHE_BY_RESOURCE)
|
||||
->setResource('preview/' . $preview->getId())
|
||||
->trigger();
|
||||
|
||||
|
||||
$this->database->updateDocument(
|
||||
'videos',
|
||||
$this->video->getId(),
|
||||
new document(
|
||||
array_filter((array)$this->video, fn ($value) => !is_null($value))
|
||||
),
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -367,9 +374,11 @@ class VideosV1 extends Worker
|
||||
'audioBitRate' => $this->profile->getAttribute('audioBitRate'),
|
||||
'output' => $this->args['output'],
|
||||
]));
|
||||
|
||||
$this->send($query);
|
||||
|
||||
$renditionRootPath = $this->getVideoDevice($this->project->getId())->getPath($this->video->getId()) . '/';
|
||||
$renditionPath = $renditionRootPath . $this->renditionName . '-' . $query->getId() . '/';
|
||||
$renditionPath = $renditionRootPath . $this->renditionName . '-' . $query->getId() . '/';
|
||||
|
||||
try {
|
||||
$representation = (new Representation())
|
||||
@@ -451,8 +460,8 @@ class VideosV1 extends Worker
|
||||
foreach ($m3u8['segments'] ?? [] as $segment) {
|
||||
$this->database->createDocument('videos_subtitles_segments', new Document([
|
||||
'subtitleId' => $subtitle->getId(),
|
||||
'fileName' => $segment['fileName'],
|
||||
'path' => $renditionRootPath ,
|
||||
'fileName' => $segment['fileName'],
|
||||
'path' => $renditionRootPath . 'subtitles/',
|
||||
'duration' => $segment['duration'],
|
||||
]));
|
||||
}
|
||||
@@ -462,7 +471,7 @@ class VideosV1 extends Worker
|
||||
}
|
||||
|
||||
$subtitle->setAttribute('status', self::STATUS_READY);
|
||||
$subtitle->setAttribute('path', $renditionRootPath);
|
||||
$subtitle->setAttribute('path', $renditionRootPath . 'subtitles/');
|
||||
$this->database->updateDocument('videos_subtitles', $subtitle->getId(), $subtitle);
|
||||
}
|
||||
|
||||
@@ -477,7 +486,7 @@ class VideosV1 extends Worker
|
||||
$data = (new Local('/'))->read($this->outDir . $fileinfo->getFilename());
|
||||
$to = $renditionPath;
|
||||
if (str_contains($fileinfo->getFilename(), "_subtitles_") || str_contains($fileinfo->getFilename(), ".vtt")) {
|
||||
$to = $renditionRootPath;
|
||||
$to = $renditionRootPath . 'subtitles/';
|
||||
}
|
||||
|
||||
$this->getVideoDevice($this->project->getId())->write($to . $fileinfo->getFilename(), $data);
|
||||
|
||||
Reference in New Issue
Block a user