aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-video-miniature/video-download.component.ts
diff options
context:
space:
mode:
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.ts27
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 @@
1import { mapValues, pick } from 'lodash-es' 1import { mapValues } from 'lodash-es'
2import { firstValueFrom } from 'rxjs' 2import { firstValueFrom } from 'rxjs'
3import { tap } from 'rxjs/operators' 3import { tap } from 'rxjs/operators'
4import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core' 4import { Component, ElementRef, Inject, LOCALE_ID, ViewChild } from '@angular/core'
@@ -6,11 +6,12 @@ import { HooksService } from '@app/core'
6import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
7import { logger } from '@root-helpers/logger' 7import { logger } from '@root-helpers/logger'
8import { videoRequiresAuth } from '@root-helpers/video' 8import { videoRequiresAuth } from '@root-helpers/video'
9import { objectKeysTyped, pick } from '@shared/core-utils'
9import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models' 10import { VideoCaption, VideoFile, VideoPrivacy } from '@shared/models'
10import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoFileTokenService, VideoService } from '../shared-main' 11import { BytesPipe, NumberFormatterPipe, VideoDetails, VideoFileTokenService, VideoService } from '../shared-main'
11 12
12type DownloadType = 'video' | 'subtitles' 13type DownloadType = 'video' | 'subtitles'
13type FileMetadata = { [key: string]: { label: string, value: string } } 14type 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