diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/app/videos/+video-edit/video-add-components/video-import-url.component.ts | 37 |
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' | |||
11 | import { FormValidatorService } from '@app/shared' | 11 | import { FormValidatorService } from '@app/shared' |
12 | import { VideoCaptionService } from '@app/shared/video-caption' | 12 | import { VideoCaptionService } from '@app/shared/video-caption' |
13 | import { VideoImportService } from '@app/shared/video-import' | 13 | import { VideoImportService } from '@app/shared/video-import' |
14 | import { scrollToTop } from '@app/shared/misc/utils' | 14 | import { scrollToTop, getAbsoluteAPIUrl } from '@app/shared/misc/utils' |
15 | import { switchMap, map } from 'rxjs/operators' | 15 | import { 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 | } |