diff options
Diffstat (limited to 'client/src/app/shared/shared-video-miniature/video-download.component.ts')
-rw-r--r-- | client/src/app/shared/shared-video-miniature/video-download.component.ts | 27 |
1 files changed, 14 insertions, 13 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 4135542dc..cac82d8d0 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,4 +1,4 @@ | |||
1 | import { mapValues, pick } from 'lodash-es' | 1 | import { mapValues } from 'lodash-es' |
2 | import { firstValueFrom } from 'rxjs' | 2 | import { firstValueFrom } from 'rxjs' |
3 | import { tap } from 'rxjs/operators' | 3 | import { tap } from 'rxjs/operators' |
4 | import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' | 4 | import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' |
@@ -6,11 +6,12 @@ import { HooksService } from '@app/core' | |||
6 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' |
7 | import { logger } from '@root-helpers/logger' | 7 | import { logger } from '@root-helpers/logger' |
8 | import { videoRequiresAuth } from '@root-helpers/video' | 8 | import { videoRequiresAuth } from '@root-helpers/video' |
9 | import { objectKeysTyped, pick } from '@shared/core-utils' | ||
9 | import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models' | 10 | import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models' |
10 | import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoFileTokenService, VideoService } from '../shared-main' | 11 | import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoFileTokenService, VideoService } from '../shared-main' |
11 | 12 | ||
12 | type DownloadType = 'video' | 'subtitles' | 13 | type DownloadType = 'video' | 'subtitles' |
13 | type FileMetadata = { [key: string]: { label: string, value: string } } | 14 | type FileMetadata = { [key: string]: { label: string, value: string | number } } |
14 | 15 | ||
15 | @Component({ | 16 | @Component({ |
16 | selector: 'my-video-download', | 17 | selector: 'my-video-download', |
@@ -218,10 +219,10 @@ export class VideoDownloadComponent { | |||
218 | const keyToTranslateFunction = { | 219 | const keyToTranslateFunction = { |
219 | encoder: (value: string) => ({ label: $localize`Encoder`, value }), | 220 | encoder: (value: string) => ({ label: $localize`Encoder`, value }), |
220 | format_long_name: (value: string) => ({ label: $localize`Format name`, value }), | 221 | format_long_name: (value: string) => ({ label: $localize`Format name`, value }), |
221 | size: (value: number) => ({ label: $localize`Size`, value: this.bytesPipe.transform(value, 2) }), | 222 | size: (value: number | string) => ({ label: $localize`Size`, value: this.bytesPipe.transform(+value, 2) }), |
222 | bit_rate: (value: number) => ({ | 223 | bit_rate: (value: number | string) => ({ |
223 | label: $localize`Bitrate`, | 224 | label: $localize`Bitrate`, |
224 | value: `${this.numbersPipe.transform(value)}bps` | 225 | value: `${this.numbersPipe.transform(+value)}bps` |
225 | }) | 226 | }) |
226 | } | 227 | } |
227 | 228 | ||
@@ -230,8 +231,8 @@ export class VideoDownloadComponent { | |||
230 | delete sanitizedFormat.tags | 231 | delete sanitizedFormat.tags |
231 | 232 | ||
232 | return mapValues( | 233 | return mapValues( |
233 | pick(sanitizedFormat, Object.keys(keyToTranslateFunction)), | 234 | pick(sanitizedFormat, objectKeysTyped(keyToTranslateFunction)), |
234 | (val, key) => keyToTranslateFunction[key](val) | 235 | (val: string, key: keyof typeof keyToTranslateFunction) => keyToTranslateFunction[key](val) |
235 | ) | 236 | ) |
236 | } | 237 | } |
237 | 238 | ||
@@ -242,29 +243,29 @@ export class VideoDownloadComponent { | |||
242 | let keyToTranslateFunction = { | 243 | let keyToTranslateFunction = { |
243 | codec_long_name: (value: string) => ({ label: $localize`Codec`, value }), | 244 | codec_long_name: (value: string) => ({ label: $localize`Codec`, value }), |
244 | profile: (value: string) => ({ label: $localize`Profile`, value }), | 245 | profile: (value: string) => ({ label: $localize`Profile`, value }), |
245 | bit_rate: (value: number) => ({ | 246 | bit_rate: (value: number | string) => ({ |
246 | label: $localize`Bitrate`, | 247 | label: $localize`Bitrate`, |
247 | value: `${this.numbersPipe.transform(value)}bps` | 248 | value: `${this.numbersPipe.transform(+value)}bps` |
248 | }) | 249 | }) |
249 | } | 250 | } |
250 | 251 | ||
251 | if (type === 'video') { | 252 | if (type === 'video') { |
252 | keyToTranslateFunction = Object.assign(keyToTranslateFunction, { | 253 | keyToTranslateFunction = Object.assign(keyToTranslateFunction, { |
253 | width: (value: number) => ({ label: $localize`Resolution`, value: `${value}x${stream.height}` }), | 254 | width: (value: string | number) => ({ label: $localize`Resolution`, value: `${value}x${stream.height}` }), |
254 | display_aspect_ratio: (value: string) => ({ label: $localize`Aspect ratio`, value }), | 255 | display_aspect_ratio: (value: string) => ({ label: $localize`Aspect ratio`, value }), |
255 | avg_frame_rate: (value: string) => ({ label: $localize`Average frame rate`, value }), | 256 | avg_frame_rate: (value: string) => ({ label: $localize`Average frame rate`, value }), |
256 | pix_fmt: (value: string) => ({ label: $localize`Pixel format`, value }) | 257 | pix_fmt: (value: string) => ({ label: $localize`Pixel format`, value }) |
257 | }) | 258 | }) |
258 | } else { | 259 | } else { |
259 | keyToTranslateFunction = Object.assign(keyToTranslateFunction, { | 260 | keyToTranslateFunction = Object.assign(keyToTranslateFunction, { |
260 | sample_rate: (value: number) => ({ label: $localize`Sample rate`, value }), | 261 | sample_rate: (value: string | number) => ({ label: $localize`Sample rate`, value }), |
261 | channel_layout: (value: number) => ({ label: $localize`Channel Layout`, value }) | 262 | channel_layout: (value: string | number) => ({ label: $localize`Channel Layout`, value }) |
262 | }) | 263 | }) |
263 | } | 264 | } |
264 | 265 | ||
265 | return mapValues( | 266 | return mapValues( |
266 | pick(stream, Object.keys(keyToTranslateFunction)), | 267 | pick(stream, Object.keys(keyToTranslateFunction)), |
267 | (val, key) => keyToTranslateFunction[key](val) | 268 | (val: string, key: keyof typeof keyToTranslateFunction) => keyToTranslateFunction[key](val) |
268 | ) | 269 | ) |
269 | } | 270 | } |
270 | 271 | ||