From e57c3024f42c7f84d77ddee1dc7bc71b845f9a68 Mon Sep 17 00:00:00 2001 From: chagai95 <31655082+chagai95@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:47:18 +0100 Subject: [PATCH] Add config option to keep original video file (basic first version) (#6157) * testing not removing old file and adding columb to db * implement feature * remove unnecessary config changes * use only keptOriginalFileName, change keptOriginalFileName to keptOriginalFilename for consistency with with videoFile table, slight refactor with basename() * save original video files to dedicated directory original-video-files * begin implementing object storage (bucket) support --------- Co-authored-by: chagai.friedlander Co-authored-by: Ian Co-authored-by: Chocobozzz --- .../edit-custom-config.component.ts | 3 + .../edit-vod-transcoding.component.html | 15 +- .../shared/shared-main/video/video.service.ts | 2 +- .../video-download.component.html | 105 +++++--- .../video-download.component.scss | 27 +- .../video-download.component.ts | 133 ++++++---- client/src/assets/images/misc/shield.svg | 2 +- config/default.yaml | 14 +- config/dev.yaml | 3 + config/production.yaml.example | 12 + config/test-1.yaml | 1 + config/test-2.yaml | 1 + config/test-3.yaml | 1 + config/test-4.yaml | 1 + config/test-5.yaml | 1 + config/test-6.yaml | 1 + .../video-export.model.ts | 13 +- .../models/src/server/custom-config.model.ts | 4 + .../models/src/videos/video-source.model.ts | 21 +- .../src/server/config-command.ts | 28 +- .../src/server/object-storage-command.ts | 26 +- packages/server-commands/src/server/server.ts | 1 + .../src/server/servers-command.ts | 20 +- .../src/users/user-exports-command.ts | 23 +- packages/tests/src/api/check-params/config.ts | 240 +----------------- .../src/api/check-params/video-source.ts | 65 ++++- packages/tests/src/api/server/config.ts | 5 + packages/tests/src/api/users/user-export.ts | 39 ++- packages/tests/src/api/users/user-import.ts | 91 +++++-- packages/tests/src/api/videos/video-source.ts | 186 +++++++++++--- packages/tests/src/peertube-runner/index.ts | 1 + .../tests/src/peertube-runner/replace-file.ts | 86 +++++++ packages/tests/src/shared/videos.ts | 61 ++++- server/core/controllers/api/config.ts | 3 + server/core/controllers/api/videos/live.ts | 4 +- server/core/controllers/api/videos/source.ts | 25 +- server/core/controllers/api/videos/upload.ts | 21 +- server/core/controllers/download.ts | 53 +++- server/core/controllers/static.ts | 4 +- .../core/initializers/checker-after-init.ts | 58 ++++- .../core/initializers/checker-before-init.ts | 7 +- server/core/initializers/config.ts | 9 + server/core/initializers/constants.ts | 9 +- server/core/initializers/installer.ts | 4 +- .../migrations/0830-keep-original-file.ts | 91 +++++++ .../job-queue/handlers/video-live-ending.ts | 5 +- server/core/lib/local-video-creator.ts | 53 ++-- server/core/lib/object-storage/keys.ts | 15 +- .../lib/object-storage/pre-signed-urls.ts | 31 ++- server/core/lib/object-storage/urls.ts | 33 +-- server/core/lib/object-storage/videos.ts | 95 ++++--- server/core/lib/thumbnail.ts | 5 +- .../transcoding-runner-job-builder.ts | 8 +- .../core/lib/transcoding/web-transcoding.ts | 27 +- .../exporters/videos-exporter.ts | 96 ++++--- .../importers/videos-importer.ts | 52 ++-- .../lib/user-import-export/user-exporter.ts | 14 +- server/core/lib/video-file.ts | 118 +++++++-- server/core/lib/video-path-manager.ts | 16 +- server/core/lib/video-privacy.ts | 4 +- server/core/middlewares/validators/config.ts | 1 + .../middlewares/validators/shared/videos.ts | 82 +++--- .../validators/videos/shared/upload.ts | 11 +- .../validators/videos/video-source.ts | 35 ++- .../middlewares/validators/videos/videos.ts | 33 +-- server/core/models/user/user-export.ts | 6 +- .../video/formatter/video-api-format.ts | 20 +- server/core/models/video/video-file.ts | 13 +- server/core/models/video/video-source.ts | 89 ++++++- .../models/video/video-streaming-playlist.ts | 6 +- server/core/models/video/video.ts | 21 +- server/core/types/express.d.ts | 9 +- server/scripts/migrations/peertube-5.0.ts | 2 +- server/scripts/prune-storage.ts | 6 +- support/doc/api/openapi.yaml | 28 ++ 75 files changed, 1653 insertions(+), 801 deletions(-) create mode 100644 packages/tests/src/peertube-runner/replace-file.ts create mode 100644 server/core/initializers/migrations/0830-keep-original-file.ts diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index 08fb9e29e..6c14b5c55 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -226,6 +226,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { concurrency: CONCURRENCY_VALIDATOR, resolutions: {}, alwaysTranscodeOriginalResolution: null, + originalFile: { + keep: null + }, hls: { enabled: null }, diff --git a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html index 588829a82..b82850858 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.html @@ -39,7 +39,7 @@
-

Input formats

+

Input

+ +
+ + +
If enabled, the input file is not deleted after transcoding but moved in a dedicated folder or object storage
+
+
+
-

Output formats

+

Output

diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts index f2ee6f3dc..24bc9fee4 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -405,7 +405,7 @@ export class VideoService { getSource (videoId: number) { return this.authHttp - .get<{ source: VideoSource }>(VideoService.BASE_VIDEO_URL + '/' + videoId + '/source') + .get(VideoService.BASE_VIDEO_URL + '/' + videoId + '/source') .pipe( catchError(err => { if (err.status === 404) { diff --git a/client/src/app/shared/shared-video-miniature/video-download.component.html b/client/src/app/shared/shared-video-miniature/video-download.component.html index 7426aafe1..dd76754bb 100644 --- a/client/src/app/shared/shared-video-miniature/video-download.component.html +++ b/client/src/app/shared/shared-video-miniature/video-download.component.html @@ -16,7 +16,7 @@
-