From 43cb1772c178767eae447fe74452a8bb3c81b5a2 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Fri, 26 May 2023 11:44:21 +0400 Subject: [PATCH] Allow to edit video attribute "importedFrom" with the UI --- .../shared/video-edit.component.html | 23 +++++++++++++++++++ .../shared/video-edit.component.ts | 1 + .../shared-main/video/video-edit.model.ts | 3 +++ .../shared/shared-main/video/video.service.ts | 2 ++ server/controllers/api/videos/update.ts | 3 ++- server/lib/video.ts | 1 + shared/models/videos/video-create.model.ts | 1 + shared/models/videos/video-update.model.ts | 1 + support/doc/api/openapi.yaml | 4 ++++ 9 files changed, 38 insertions(+), 1 deletion(-) diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html index fdd6b2311..0fc889c4c 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.html @@ -350,6 +350,29 @@ +
+ + + + + + The URL where this video is imported from + + + + + + +
+ {{ formErrors.importedFrom }} +
+
+
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts index 89687f35e..df8a034ab 100644 --- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts @@ -161,6 +161,7 @@ export class VideoEditComponent implements OnInit, OnDestroy { previewfile: null, support: VIDEO_SUPPORT_VALIDATOR, schedulePublicationAt: VIDEO_SCHEDULE_PUBLICATION_AT_VALIDATOR, + importedFrom: null, originallyPublishedAt: VIDEO_ORIGINALLY_PUBLISHED_AT_VALIDATOR, liveStreamKey: null, permanentLive: null, diff --git a/client/src/app/shared/shared-main/video/video-edit.model.ts b/client/src/app/shared/shared-main/video/video-edit.model.ts index 91d57cb6b..772d048ec 100644 --- a/client/src/app/shared/shared-main/video/video-edit.model.ts +++ b/client/src/app/shared/shared-main/video/video-edit.model.ts @@ -23,6 +23,7 @@ export class VideoEdit implements VideoUpdate { thumbnailUrl: string previewUrl: string scheduleUpdate?: VideoScheduleUpdate + importedFrom?: string originallyPublishedAt?: Date | string id?: number @@ -57,6 +58,7 @@ export class VideoEdit implements VideoUpdate { if (video.previewPath) this.previewUrl = getAbsoluteAPIUrl() + video.previewPath this.scheduleUpdate = video.scheduledUpdate + this.importedFrom = video.importedFrom this.originallyPublishedAt = video.originallyPublishedAt ? new Date(video.originallyPublishedAt) : null @@ -110,6 +112,7 @@ export class VideoEdit implements VideoUpdate { waitTranscoding: this.waitTranscoding, channelId: this.channelId, privacy: this.privacy, + importedFrom: this.importedFrom, originallyPublishedAt: this.originallyPublishedAt } 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 152149827..b0d0d2940 100644 --- a/client/src/app/shared/shared-main/video/video.service.ts +++ b/client/src/app/shared/shared-main/video/video.service.ts @@ -87,6 +87,7 @@ export class VideoService { const description = video.description || null const support = video.support || null const scheduleUpdate = video.scheduleUpdate || null + const importedFrom = video.importedFrom || null const originallyPublishedAt = video.originallyPublishedAt || null const body: VideoUpdate = { @@ -107,6 +108,7 @@ export class VideoService { previewfile: video.previewfile, pluginData: video.pluginData, scheduleUpdate, + importedFrom, originallyPublishedAt } diff --git a/server/controllers/api/videos/update.ts b/server/controllers/api/videos/update.ts index e6197c4b1..1d400efe2 100644 --- a/server/controllers/api/videos/update.ts +++ b/server/controllers/api/videos/update.ts @@ -77,7 +77,8 @@ async function updateVideo (req: express.Request, res: express.Response) { 'support', 'description', 'commentsEnabled', - 'downloadEnabled' + 'downloadEnabled', + 'importedFrom' ] for (const key of keysToUpdate) { diff --git a/server/lib/video.ts b/server/lib/video.ts index aacc41a7a..814e254b5 100644 --- a/server/lib/video.ts +++ b/server/lib/video.ts @@ -28,6 +28,7 @@ function buildLocalVideoFromReq (videoInfo: VideoCreate, channelId: number): Fil support: videoInfo.support, privacy: videoInfo.privacy || VideoPrivacy.PRIVATE, channelId, + importedFrom: null, originallyPublishedAt: videoInfo.originallyPublishedAt ? new Date(videoInfo.originallyPublishedAt) : null diff --git a/shared/models/videos/video-create.model.ts b/shared/models/videos/video-create.model.ts index 732d508d1..5bafb0048 100644 --- a/shared/models/videos/video-create.model.ts +++ b/shared/models/videos/video-create.model.ts @@ -17,6 +17,7 @@ export interface VideoCreate { downloadEnabled?: boolean privacy: VideoPrivacy scheduleUpdate?: VideoScheduleUpdate + importedFrom?: string originallyPublishedAt?: Date | string thumbnailfile?: Blob | string diff --git a/shared/models/videos/video-update.model.ts b/shared/models/videos/video-update.model.ts index 86653b959..0cccc3df8 100644 --- a/shared/models/videos/video-update.model.ts +++ b/shared/models/videos/video-update.model.ts @@ -18,6 +18,7 @@ export interface VideoUpdate { thumbnailfile?: Blob previewfile?: Blob scheduleUpdate?: VideoScheduleUpdate + importedFrom?: string originallyPublishedAt?: Date | string pluginData?: any diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index 9000e4fd2..bc3e52445 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml @@ -6426,6 +6426,10 @@ components: format: date-time example: 2021-05-04T08:01:01.502Z description: last time the video's metadata was modified + importedFrom: + type: string + example: https://youtu.be/fe8agy1pb44 + description: the URL where this video is imported from originallyPublishedAt: type: string format: date-time