From 9c761fb9e06c609dec35444be9b7b75e9ee1b078 Mon Sep 17 00:00:00 2001 From: Wicklow Date: Tue, 17 Oct 2023 17:22:11 +0200 Subject: [PATCH] Add ability to download videos from my videos page --- .../my-videos/my-videos.component.ts | 2 +- .../shared/shared-main/video/video.model.ts | 8 ++++++++ .../video-actions-dropdown.component.ts | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index 4a7604878..caa3bcb44 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts @@ -48,7 +48,7 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { } videoDropdownDisplayOptions: VideoActionsDisplayType = { playlist: false, - download: false, + download: true, update: false, blacklist: false, delete: true, diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts index ed28fb3f8..584cdace5 100644 --- a/client/src/app/shared/shared-main/video/video.model.ts +++ b/client/src/app/shared/shared-main/video/video.model.ts @@ -251,6 +251,14 @@ export class Video implements VideoServerModel { this.hasWebVideos() } + isDownloadableBy (user: AuthUser) { + if (!user || this.isLocal !== true) { + return false + } + + return this.account.name === user.username || user.hasRight(UserRight.MANAGE_VIDEO_FILES) + } + canRunTranscoding (user: AuthUser) { return this.canRunForcedTranscoding(user) && this.state.id !== VideoState.TO_TRANSCODE } diff --git a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts index 4b3ed6e99..1862a3b7b 100644 --- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts +++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts @@ -127,8 +127,13 @@ export class VideoActionsDropdownComponent implements OnChanges { showDownloadModal () { this.modalOpened.emit() - - this.videoDownloadModal.show(this.video as VideoDetails, this.videoCaptions) + if (!(this.video instanceof VideoDetails)) { + this.videoService.getVideo({ videoId: this.video.uuid }).subscribe((details: VideoDetails) => { + this.videoDownloadModal.show(details, this.videoCaptions) + }) + } else { + this.videoDownloadModal.show(this.video, this.videoCaptions) + } } showReportModal () { @@ -180,10 +185,11 @@ export class VideoActionsDropdownComponent implements OnChanges { } isVideoDownloadable () { - return this.video && - this.video.isLive !== true && - this.video instanceof VideoDetails && - this.video.downloadEnabled + if (!this.video || this.video.isLive) { + return false + } + + return (this.video instanceof VideoDetails && this.video.downloadEnabled) || this.video.isDownloadableBy(this.user) } canVideoBeDuplicated () {