aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-03-23 11:54:08 +0100
committerChocobozzz <me@florianbigard.com>2021-03-24 18:18:41 +0100
commit4bc45da342597fb49593fc14c40f8dc5a97bb64e (patch)
tree9fa876e21995b27827fbc4467bd71b8d427312e2 /client
parentc0ab041c2c749db05ce564d3078c2ad10d18f35f (diff)
downloadPeerTube-4bc45da342597fb49593fc14c40f8dc5a97bb64e.tar.gz
PeerTube-4bc45da342597fb49593fc14c40f8dc5a97bb64e.tar.zst
PeerTube-4bc45da342597fb49593fc14c40f8dc5a97bb64e.zip
Add hooks support for video download
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/shared-video-miniature/video-download.component.ts19
1 files changed, 14 insertions, 5 deletions
diff --git a/client/src/app/shared/shared-video-miniature/video-download.component.ts b/client/src/app/shared/shared-video-miniature/video-download.component.ts
index 90f4daf7c..a57e4ce6d 100644
--- a/client/src/app/shared/shared-video-miniature/video-download.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-download.component.ts
@@ -1,7 +1,9 @@
1import { mapValues, pick } from 'lodash-es' 1import { mapValues, pick } from 'lodash-es'
2import { pipe } from 'rxjs'
3import { tap } from 'rxjs/operators'
2import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' 4import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core'
3import { AuthService, Notifier } from '@app/core' 5import { AuthService, HooksService, Notifier } from '@app/core'
4import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
5import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models' 7import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models'
6import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main' 8import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoService } from '../shared-main'
7 9
@@ -26,7 +28,7 @@ export class VideoDownloadComponent {
26 videoFileMetadataVideoStream: FileMetadata | undefined 28 videoFileMetadataVideoStream: FileMetadata | undefined
27 videoFileMetadataAudioStream: FileMetadata | undefined 29 videoFileMetadataAudioStream: FileMetadata | undefined
28 videoCaptions: VideoCaption[] 30 videoCaptions: VideoCaption[]
29 activeModal: NgbActiveModal 31 activeModal: NgbModalRef
30 32
31 type: DownloadType = 'video' 33 type: DownloadType = 'video'
32 34
@@ -38,7 +40,8 @@ export class VideoDownloadComponent {
38 private notifier: Notifier, 40 private notifier: Notifier,
39 private modalService: NgbModal, 41 private modalService: NgbModal,
40 private videoService: VideoService, 42 private videoService: VideoService,
41 private auth: AuthService 43 private auth: AuthService,
44 private hooks: HooksService
42 ) { 45 ) {
43 this.bytesPipe = new BytesPipe() 46 this.bytesPipe = new BytesPipe()
44 this.numbersPipe = new NumberFormatterPipe(this.localeId) 47 this.numbersPipe = new NumberFormatterPipe(this.localeId)
@@ -64,7 +67,12 @@ export class VideoDownloadComponent {
64 67
65 this.resolutionId = this.getVideoFiles()[0].resolution.id 68 this.resolutionId = this.getVideoFiles()[0].resolution.id
66 this.onResolutionIdChange() 69 this.onResolutionIdChange()
70
67 if (this.videoCaptions) this.subtitleLanguageId = this.videoCaptions[0].language.id 71 if (this.videoCaptions) this.subtitleLanguageId = this.videoCaptions[0].language.id
72
73 this.activeModal.shown.subscribe(() => {
74 this.hooks.runAction('action:modal.video-download.shown', 'common')
75 })
68 } 76 }
69 77
70 onClose () { 78 onClose () {
@@ -88,6 +96,7 @@ export class VideoDownloadComponent {
88 if (this.videoFile.metadata || !this.videoFile.metadataUrl) return 96 if (this.videoFile.metadata || !this.videoFile.metadataUrl) return
89 97
90 await this.hydrateMetadataFromMetadataUrl(this.videoFile) 98 await this.hydrateMetadataFromMetadataUrl(this.videoFile)
99 if (!this.videoFile.metadata) return
91 100
92 this.videoFileMetadataFormat = this.videoFile 101 this.videoFileMetadataFormat = this.videoFile
93 ? this.getMetadataFormat(this.videoFile.metadata.format) 102 ? this.getMetadataFormat(this.videoFile.metadata.format)
@@ -201,7 +210,7 @@ export class VideoDownloadComponent {
201 210
202 private hydrateMetadataFromMetadataUrl (file: VideoFile) { 211 private hydrateMetadataFromMetadataUrl (file: VideoFile) {
203 const observable = this.videoService.getVideoFileMetadata(file.metadataUrl) 212 const observable = this.videoService.getVideoFileMetadata(file.metadataUrl)
204 observable.subscribe(res => file.metadata = res) 213 .pipe(tap(res => file.metadata = res))
205 214
206 return observable.toPromise() 215 return observable.toPromise()
207 } 216 }