aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-29 11:32:46 +0200
committerChocobozzz <me@florianbigard.com>2022-07-29 11:33:27 +0200
commit12d84abeca4917d2f1e3f308010bfcd56d37cb7c (patch)
tree95c6b42ed4af5fa81afd2f8ff0d6520bcbf9bd48
parent5a9a56b78f6a62b3241f0dff1b8685001a3b3a1d (diff)
downloadPeerTube-12d84abeca4917d2f1e3f308010bfcd56d37cb7c.tar.gz
PeerTube-12d84abeca4917d2f1e3f308010bfcd56d37cb7c.tar.zst
PeerTube-12d84abeca4917d2f1e3f308010bfcd56d37cb7c.zip
Include video file id in API
-rw-r--r--server/models/video/formatter/video-format-utils.ts2
-rw-r--r--server/tests/shared/videos.ts1
-rw-r--r--shared/models/videos/file/video-file.model.ts2
-rw-r--r--support/doc/api/openapi.yaml2
4 files changed, 7 insertions, 0 deletions
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 (
256 .sort(sortByResolutionDesc) 256 .sort(sortByResolutionDesc)
257 .map(videoFile => { 257 .map(videoFile => {
258 return { 258 return {
259 id: videoFile.id,
260
259 resolution: { 261 resolution: {
260 id: videoFile.resolution, 262 id: videoFile.resolution,
261 label: videoFile.resolution === 0 ? 'Audio' : `${videoFile.resolution}p` 263 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 (
115 // Transcoding enabled: extension will always be .mp4 115 // Transcoding enabled: extension will always be .mp4
116 if (attributes.files.length > 1) extension = '.mp4' 116 if (attributes.files.length > 1) extension = '.mp4'
117 117
118 expect(file.id).to.exist
118 expect(file.magnetUri).to.have.lengthOf.above(2) 119 expect(file.magnetUri).to.have.lengthOf.above(2)
119 120
120 expect(file.torrentDownloadUrl).to.match(new RegExp(`http://${host}/download/torrents/${uuidRegex}-${file.resolution.id}.torrent`)) 121 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'
3import { VideoResolution } from './video-resolution.enum' 3import { VideoResolution } from './video-resolution.enum'
4 4
5export interface VideoFile { 5export interface VideoFile {
6 id: number
7
6 resolution: VideoConstant<VideoResolution> 8 resolution: VideoConstant<VideoResolution>
7 size: number // Bytes 9 size: number // Bytes
8 10
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:
5665 VideoFile: 5665 VideoFile:
5666 readOnly: true 5666 readOnly: true
5667 properties: 5667 properties:
5668 id:
5669 $ref: '#/components/schemas/id'
5668 magnetUri: 5670 magnetUri:
5669 type: string 5671 type: string
5670 format: uri 5672 format: uri