aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-16 16:25:53 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-18 13:38:09 +0100
commit90a8bd305de4153ec21137a73ff482dcc2e3e19b (patch)
tree2e35b5504ec11bc51579c92a70c77ed3d5ace816 /shared
parent684cdacbbd775b5f404dd7b373e02dd21baf5ff0 (diff)
downloadPeerTube-90a8bd305de4153ec21137a73ff482dcc2e3e19b.tar.gz
PeerTube-90a8bd305de4153ec21137a73ff482dcc2e3e19b.tar.zst
PeerTube-90a8bd305de4153ec21137a73ff482dcc2e3e19b.zip
Dissociate video file names and video uuid
Diffstat (limited to 'shared')
-rw-r--r--shared/extra-utils/videos/videos.ts22
-rw-r--r--shared/models/videos/video-file.model.ts8
2 files changed, 26 insertions, 4 deletions
diff --git a/shared/extra-utils/videos/videos.ts b/shared/extra-utils/videos/videos.ts
index f94fa233c..929eb42ca 100644
--- a/shared/extra-utils/videos/videos.ts
+++ b/shared/extra-utils/videos/videos.ts
@@ -11,7 +11,7 @@ import validator from 'validator'
11import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' 11import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants'
12import { VideoDetails, VideoPrivacy } from '../../models/videos' 12import { VideoDetails, VideoPrivacy } from '../../models/videos'
13import { buildAbsoluteFixturePath, buildServerDirectory, dateIsValid, immutableAssign, testImage, webtorrentAdd } from '../miscs/miscs' 13import { buildAbsoluteFixturePath, buildServerDirectory, dateIsValid, immutableAssign, testImage, webtorrentAdd } from '../miscs/miscs'
14import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests' 14import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests'
15import { waitJobs } from '../server/jobs' 15import { waitJobs } from '../server/jobs'
16import { ServerInfo } from '../server/servers' 16import { ServerInfo } from '../server/servers'
17import { getMyUserInformation } from '../users/users' 17import { getMyUserInformation } from '../users/users'
@@ -544,6 +544,9 @@ async function completeVideoCheck (
544 if (!attributes.likes) attributes.likes = 0 544 if (!attributes.likes) attributes.likes = 0
545 if (!attributes.dislikes) attributes.dislikes = 0 545 if (!attributes.dislikes) attributes.dislikes = 0
546 546
547 const host = new URL(url).host
548 const originHost = attributes.account.host
549
547 expect(video.name).to.equal(attributes.name) 550 expect(video.name).to.equal(attributes.name)
548 expect(video.category.id).to.equal(attributes.category) 551 expect(video.category.id).to.equal(attributes.category)
549 expect(video.category.label).to.equal(attributes.category !== null ? VIDEO_CATEGORIES[attributes.category] : 'Misc') 552 expect(video.category.label).to.equal(attributes.category !== null ? VIDEO_CATEGORIES[attributes.category] : 'Misc')
@@ -603,8 +606,21 @@ async function completeVideoCheck (
603 if (attributes.files.length > 1) extension = '.mp4' 606 if (attributes.files.length > 1) extension = '.mp4'
604 607
605 expect(file.magnetUri).to.have.lengthOf.above(2) 608 expect(file.magnetUri).to.have.lengthOf.above(2)
606 expect(file.torrentUrl).to.equal(`http://${attributes.account.host}/static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`) 609
607 expect(file.fileUrl).to.equal(`http://${attributes.account.host}/static/webseed/${videoDetails.uuid}-${file.resolution.id}${extension}`) 610 expect(file.torrentDownloadUrl).to.equal(`http://${host}/download/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`)
611 expect(file.torrentUrl).to.equal(`http://${host}/lazy-static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`)
612
613 expect(file.fileUrl).to.equal(`http://${originHost}/static/webseed/${videoDetails.uuid}-${file.resolution.id}${extension}`)
614 expect(file.fileDownloadUrl).to.equal(`http://${originHost}/download/videos/${videoDetails.uuid}-${file.resolution.id}${extension}`)
615
616 await Promise.all([
617 makeRawRequest(file.torrentUrl, 200),
618 makeRawRequest(file.torrentDownloadUrl, 200),
619 makeRawRequest(file.metadataUrl, 200),
620 // Backward compatibility
621 makeRawRequest(`http://${originHost}/static/torrents/${videoDetails.uuid}-${file.resolution.id}.torrent`, 200)
622 ])
623
608 expect(file.resolution.id).to.equal(attributeFile.resolution) 624 expect(file.resolution.id).to.equal(attributeFile.resolution)
609 expect(file.resolution.label).to.equal(attributeFile.resolution + 'p') 625 expect(file.resolution.label).to.equal(attributeFile.resolution + 'p')
610 626
diff --git a/shared/models/videos/video-file.model.ts b/shared/models/videos/video-file.model.ts
index e9839229d..f3d93f0ed 100644
--- a/shared/models/videos/video-file.model.ts
+++ b/shared/models/videos/video-file.model.ts
@@ -3,14 +3,20 @@ import { VideoFileMetadata } from './video-file-metadata'
3import { VideoResolution } from './video-resolution.enum' 3import { VideoResolution } from './video-resolution.enum'
4 4
5export interface VideoFile { 5export interface VideoFile {
6 magnetUri: string
7 resolution: VideoConstant<VideoResolution> 6 resolution: VideoConstant<VideoResolution>
8 size: number // Bytes 7 size: number // Bytes
8
9 torrentUrl: string 9 torrentUrl: string
10 torrentDownloadUrl: string 10 torrentDownloadUrl: string
11
11 fileUrl: string 12 fileUrl: string
12 fileDownloadUrl: string 13 fileDownloadUrl: string
14
13 fps: number 15 fps: number
16
14 metadata?: VideoFileMetadata 17 metadata?: VideoFileMetadata
15 metadataUrl?: string 18 metadataUrl?: string
19
20 // FIXME: deprecated in 3.2
21 magnetUri: string
16} 22}