diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/videos/videos.ts | 22 | ||||
-rw-r--r-- | shared/models/videos/video-file.model.ts | 8 |
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' | |||
11 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' | 11 | import { loadLanguages, VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../../server/initializers/constants' |
12 | import { VideoDetails, VideoPrivacy } from '../../models/videos' | 12 | import { VideoDetails, VideoPrivacy } from '../../models/videos' |
13 | import { buildAbsoluteFixturePath, buildServerDirectory, dateIsValid, immutableAssign, testImage, webtorrentAdd } from '../miscs/miscs' | 13 | import { buildAbsoluteFixturePath, buildServerDirectory, dateIsValid, immutableAssign, testImage, webtorrentAdd } from '../miscs/miscs' |
14 | import { makeGetRequest, makePutBodyRequest, makeUploadRequest } from '../requests/requests' | 14 | import { makeGetRequest, makePutBodyRequest, makeRawRequest, makeUploadRequest } from '../requests/requests' |
15 | import { waitJobs } from '../server/jobs' | 15 | import { waitJobs } from '../server/jobs' |
16 | import { ServerInfo } from '../server/servers' | 16 | import { ServerInfo } from '../server/servers' |
17 | import { getMyUserInformation } from '../users/users' | 17 | import { 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' | |||
3 | import { VideoResolution } from './video-resolution.enum' | 3 | import { VideoResolution } from './video-resolution.enum' |
4 | 4 | ||
5 | export interface VideoFile { | 5 | export 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 | } |