aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-edit/video-add-components
diff options
context:
space:
mode:
authorKim <1877318+kimsible@users.noreply.github.com>2020-04-20 10:28:38 +0200
committerGitHub <noreply@github.com>2020-04-20 10:28:38 +0200
commitb1770a0af464ad6350d156245b1abcc1395e142e (patch)
tree0712a2cd912ecd3f41084134d513920a6f723fb6 /client/src/app/videos/+video-edit/video-add-components
parent8f31261f77c6e521917b3f629b223ccc8df50960 (diff)
downloadPeerTube-b1770a0af464ad6350d156245b1abcc1395e142e.tar.gz
PeerTube-b1770a0af464ad6350d156245b1abcc1395e142e.tar.zst
PeerTube-b1770a0af464ad6350d156245b1abcc1395e142e.zip
Add thumbnail / preview generation from url on the fly (#2646)
* Add thumbnails generation on the fly to URL import * Display generated preview to import first edit * Use ternary to get type inference * Move preview/thumbnail test just after import Co-authored-by: kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add-components')
-rw-r--r--client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts37
1 files changed, 34 insertions, 3 deletions
diff --git a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts
index a17d73683..213c42333 100644
--- a/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts
+++ b/client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts
@@ -11,7 +11,7 @@ import { VideoEdit } from '@app/shared/video/video-edit.model'
11import { FormValidatorService } from '@app/shared' 11import { FormValidatorService } from '@app/shared'
12import { VideoCaptionService } from '@app/shared/video-caption' 12import { VideoCaptionService } from '@app/shared/video-caption'
13import { VideoImportService } from '@app/shared/video-import' 13import { VideoImportService } from '@app/shared/video-import'
14import { scrollToTop } from '@app/shared/misc/utils' 14import { scrollToTop, getAbsoluteAPIUrl } from '@app/shared/misc/utils'
15import { switchMap, map } from 'rxjs/operators' 15import { switchMap, map } from 'rxjs/operators'
16 16
17@Component({ 17@Component({
@@ -95,12 +95,22 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
95 this.isImportingVideo = false 95 this.isImportingVideo = false
96 this.hasImportedVideo = true 96 this.hasImportedVideo = true
97 97
98 const absoluteAPIUrl = getAbsoluteAPIUrl()
99
100 const thumbnailUrl = video.thumbnailPath
101 ? absoluteAPIUrl + video.thumbnailPath
102 : null
103
104 const previewUrl = video.previewPath
105 ? absoluteAPIUrl + video.previewPath
106 : null
107
98 this.video = new VideoEdit(Object.assign(video, { 108 this.video = new VideoEdit(Object.assign(video, {
99 commentsEnabled: videoUpdate.commentsEnabled, 109 commentsEnabled: videoUpdate.commentsEnabled,
100 downloadEnabled: videoUpdate.downloadEnabled, 110 downloadEnabled: videoUpdate.downloadEnabled,
101 support: null, 111 support: null,
102 thumbnailUrl: null, 112 thumbnailUrl,
103 previewUrl: null 113 previewUrl
104 })) 114 }))
105 115
106 this.videoCaptions = videoCaptions 116 this.videoCaptions = videoCaptions
@@ -147,5 +157,26 @@ export class VideoImportUrlComponent extends VideoSend implements OnInit, CanCom
147 157
148 private hydrateFormFromVideo () { 158 private hydrateFormFromVideo () {
149 this.form.patchValue(this.video.toFormPatch()) 159 this.form.patchValue(this.video.toFormPatch())
160
161 const objects = [
162 {
163 url: 'thumbnailUrl',
164 name: 'thumbnailfile'
165 },
166 {
167 url: 'previewUrl',
168 name: 'previewfile'
169 }
170 ]
171
172 for (const obj of objects) {
173 fetch(this.video[obj.url])
174 .then(response => response.blob())
175 .then(data => {
176 this.form.patchValue({
177 [ obj.name ]: data
178 })
179 })
180 }
150 } 181 }
151} 182}