From 12d84abeca4917d2f1e3f308010bfcd56d37cb7c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Jul 2022 11:32:46 +0200 Subject: [PATCH] Include video file id in API --- server/models/video/formatter/video-format-utils.ts | 2 ++ server/tests/shared/videos.ts | 1 + shared/models/videos/file/video-file.model.ts | 2 ++ support/doc/api/openapi.yaml | 2 ++ 4 files changed, 7 insertions(+) diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts index fd02f8c64..e1b0eb610 100644 --- a/server/models/video/formatter/video-format-utils.ts +++ b/server/models/video/formatter/video-format-utils.ts @@ -256,6 +256,8 @@ function videoFilesModelToFormattedJSON ( .sort(sortByResolutionDesc) .map(videoFile => { return { + id: videoFile.id, + resolution: { id: videoFile.resolution, label: videoFile.resolution === 0 ? 'Audio' : `${videoFile.resolution}p` diff --git a/server/tests/shared/videos.ts b/server/tests/shared/videos.ts index 989865a49..3ab245392 100644 --- a/server/tests/shared/videos.ts +++ b/server/tests/shared/videos.ts @@ -115,6 +115,7 @@ async function completeVideoCheck ( // Transcoding enabled: extension will always be .mp4 if (attributes.files.length > 1) extension = '.mp4' + expect(file.id).to.exist expect(file.magnetUri).to.have.lengthOf.above(2) expect(file.torrentDownloadUrl).to.match(new RegExp(`http://${host}/download/torrents/${uuidRegex}-${file.resolution.id}.torrent`)) diff --git a/shared/models/videos/file/video-file.model.ts b/shared/models/videos/file/video-file.model.ts index 0ea857e7a..2bbff48eb 100644 --- a/shared/models/videos/file/video-file.model.ts +++ b/shared/models/videos/file/video-file.model.ts @@ -3,6 +3,8 @@ import { VideoFileMetadata } from './video-file-metadata.model' import { VideoResolution } from './video-resolution.enum' export interface VideoFile { + id: number + resolution: VideoConstant size: number // Bytes diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index 9745f68e9..3092a9960 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml @@ -5665,6 +5665,8 @@ components: VideoFile: readOnly: true properties: + id: + $ref: '#/components/schemas/id' magnetUri: type: string format: uri -- 2.41.0