Introduce captions command
This commit is contained in:
parent
e3d15a6a9a
commit
a2470c9f4b
|
@ -5,7 +5,6 @@ import * as autocannon from 'autocannon'
|
||||||
import {
|
import {
|
||||||
addVideoCommentReply,
|
addVideoCommentReply,
|
||||||
addVideoCommentThread,
|
addVideoCommentThread,
|
||||||
createVideoCaption,
|
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
killallServers,
|
killallServers,
|
||||||
|
@ -244,9 +243,7 @@ async function prepare () {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const caption of [ 'ar', 'fr', 'en', 'zh' ]) {
|
for (const caption of [ 'ar', 'fr', 'en', 'zh' ]) {
|
||||||
await createVideoCaption({
|
await server.captionsCommand.createVideoCaption({
|
||||||
url: server.url,
|
|
||||||
accessToken: server.accessToken,
|
|
||||||
language: caption,
|
language: caption,
|
||||||
videoId: video.id,
|
videoId: video.id,
|
||||||
fixture: 'subtitle-good2.vtt'
|
fixture: 'subtitle-good2.vtt'
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import { VideoCreateResult } from '@shared/models'
|
import { HttpStatusCode } from '@shared/core-utils'
|
||||||
import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
import {
|
import {
|
||||||
buildAbsoluteFixturePath,
|
buildAbsoluteFixturePath,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
|
@ -15,8 +14,8 @@ import {
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
userLogin
|
userLogin
|
||||||
} from '../../../../shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { createVideoCaption } from '../../../../shared/extra-utils/videos/video-captions'
|
import { VideoCreateResult } from '@shared/models'
|
||||||
|
|
||||||
describe('Test video captions API validator', function () {
|
describe('Test video captions API validator', function () {
|
||||||
const path = '/api/v1/videos/'
|
const path = '/api/v1/videos/'
|
||||||
|
@ -159,9 +158,7 @@ describe('Test video captions API validator', function () {
|
||||||
// })
|
// })
|
||||||
|
|
||||||
it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () {
|
it('Should succeed with a valid captionfile extension and octet-stream mime type', async function () {
|
||||||
await createVideoCaption({
|
await server.captionsCommand.createVideoCaption({
|
||||||
url: server.url,
|
|
||||||
accessToken: server.accessToken,
|
|
||||||
language: 'zh',
|
language: 'zh',
|
||||||
videoId: video.uuid,
|
videoId: video.uuid,
|
||||||
fixture: 'subtitle-good.srt',
|
fixture: 'subtitle-good.srt',
|
||||||
|
|
|
@ -4,7 +4,6 @@ import 'mocha'
|
||||||
import * as chai from 'chai'
|
import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
createVideoCaption,
|
|
||||||
flushAndRunServer,
|
flushAndRunServer,
|
||||||
immutableAssign,
|
immutableAssign,
|
||||||
SearchCommand,
|
SearchCommand,
|
||||||
|
@ -54,18 +53,14 @@ describe('Test videos search', function () {
|
||||||
const videoId = res.body.video.id
|
const videoId = res.body.video.id
|
||||||
videoUUID = res.body.video.uuid
|
videoUUID = res.body.video.uuid
|
||||||
|
|
||||||
await createVideoCaption({
|
await server.captionsCommand.createVideoCaption({
|
||||||
url: server.url,
|
|
||||||
accessToken: server.accessToken,
|
|
||||||
language: 'en',
|
language: 'en',
|
||||||
videoId,
|
videoId,
|
||||||
fixture: 'subtitle-good2.vtt',
|
fixture: 'subtitle-good2.vtt',
|
||||||
mimeType: 'application/octet-stream'
|
mimeType: 'application/octet-stream'
|
||||||
})
|
})
|
||||||
|
|
||||||
await createVideoCaption({
|
await server.captionsCommand.createVideoCaption({
|
||||||
url: server.url,
|
|
||||||
accessToken: server.accessToken,
|
|
||||||
language: 'aa',
|
language: 'aa',
|
||||||
videoId,
|
videoId,
|
||||||
fixture: 'subtitle-good2.vtt',
|
fixture: 'subtitle-good2.vtt',
|
||||||
|
|
|
@ -8,7 +8,6 @@ import {
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
completeVideoCheck,
|
completeVideoCheck,
|
||||||
createUser,
|
createUser,
|
||||||
createVideoCaption,
|
|
||||||
dateIsValid,
|
dateIsValid,
|
||||||
deleteVideoComment,
|
deleteVideoComment,
|
||||||
expectAccountFollows,
|
expectAccountFollows,
|
||||||
|
@ -17,7 +16,6 @@ import {
|
||||||
getVideoCommentThreads,
|
getVideoCommentThreads,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
getVideoThreadComments,
|
getVideoThreadComments,
|
||||||
listVideoCaptions,
|
|
||||||
rateVideo,
|
rateVideo,
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
|
@ -26,7 +24,7 @@ import {
|
||||||
userLogin,
|
userLogin,
|
||||||
waitJobs
|
waitJobs
|
||||||
} from '@shared/extra-utils'
|
} from '@shared/extra-utils'
|
||||||
import { Video, VideoCaption, VideoComment, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
|
import { Video, VideoComment, VideoCommentThreadTree, VideoPrivacy } from '@shared/models'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -385,9 +383,7 @@ describe('Test follows', function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
await createVideoCaption({
|
await servers[2].captionsCommand.createVideoCaption({
|
||||||
url: servers[2].url,
|
|
||||||
accessToken: servers[2].accessToken,
|
|
||||||
language: 'ar',
|
language: 'ar',
|
||||||
videoId: video4.id,
|
videoId: video4.id,
|
||||||
fixture: 'subtitle-good2.vtt'
|
fixture: 'subtitle-good2.vtt'
|
||||||
|
@ -543,11 +539,11 @@ describe('Test follows', function () {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should have propagated captions', async function () {
|
it('Should have propagated captions', async function () {
|
||||||
const res = await listVideoCaptions(servers[0].url, video4.id)
|
const body = await servers[0].captionsCommand.listVideoCaptions({ videoId: video4.id })
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(body.data).to.have.lengthOf(1)
|
||||||
|
|
||||||
const caption1: VideoCaption = res.body.data[0]
|
const caption1 = body.data[0]
|
||||||
expect(caption1.language.id).to.equal('ar')
|
expect(caption1.language.id).to.equal('ar')
|
||||||
expect(caption1.language.label).to.equal('Arabic')
|
expect(caption1.language.label).to.equal('Arabic')
|
||||||
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/.+-ar.vtt$'))
|
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/.+-ar.vtt$'))
|
||||||
|
|
|
@ -1,25 +1,20 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||||
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
|
import * as chai from 'chai'
|
||||||
import {
|
import {
|
||||||
checkVideoFilesWereRemoved,
|
checkVideoFilesWereRemoved,
|
||||||
cleanupTests,
|
cleanupTests,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
removeVideo,
|
removeVideo,
|
||||||
|
ServerInfo,
|
||||||
|
setAccessTokensToServers,
|
||||||
|
testCaptionFile,
|
||||||
uploadVideo,
|
uploadVideo,
|
||||||
wait
|
wait,
|
||||||
} from '../../../../shared/extra-utils'
|
waitJobs
|
||||||
import { ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index'
|
} from '@shared/extra-utils'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
|
||||||
import {
|
|
||||||
createVideoCaption,
|
|
||||||
deleteVideoCaption,
|
|
||||||
listVideoCaptions,
|
|
||||||
testCaptionFile
|
|
||||||
} from '../../../../shared/extra-utils/videos/video-captions'
|
|
||||||
import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -47,26 +42,22 @@ describe('Test video captions', function () {
|
||||||
|
|
||||||
it('Should list the captions and return an empty list', async function () {
|
it('Should list the captions and return an empty list', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const res = await listVideoCaptions(server.url, videoUUID)
|
const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
|
||||||
expect(res.body.total).to.equal(0)
|
expect(body.total).to.equal(0)
|
||||||
expect(res.body.data).to.have.lengthOf(0)
|
expect(body.data).to.have.lengthOf(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should create two new captions', async function () {
|
it('Should create two new captions', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await createVideoCaption({
|
await servers[0].captionsCommand.createVideoCaption({
|
||||||
url: servers[0].url,
|
|
||||||
accessToken: servers[0].accessToken,
|
|
||||||
language: 'ar',
|
language: 'ar',
|
||||||
videoId: videoUUID,
|
videoId: videoUUID,
|
||||||
fixture: 'subtitle-good1.vtt'
|
fixture: 'subtitle-good1.vtt'
|
||||||
})
|
})
|
||||||
|
|
||||||
await createVideoCaption({
|
await servers[0].captionsCommand.createVideoCaption({
|
||||||
url: servers[0].url,
|
|
||||||
accessToken: servers[0].accessToken,
|
|
||||||
language: 'zh',
|
language: 'zh',
|
||||||
videoId: videoUUID,
|
videoId: videoUUID,
|
||||||
fixture: 'subtitle-good2.vtt',
|
fixture: 'subtitle-good2.vtt',
|
||||||
|
@ -78,17 +69,17 @@ describe('Test video captions', function () {
|
||||||
|
|
||||||
it('Should list these uploaded captions', async function () {
|
it('Should list these uploaded captions', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const res = await listVideoCaptions(server.url, videoUUID)
|
const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
|
||||||
expect(res.body.total).to.equal(2)
|
expect(body.total).to.equal(2)
|
||||||
expect(res.body.data).to.have.lengthOf(2)
|
expect(body.data).to.have.lengthOf(2)
|
||||||
|
|
||||||
const caption1: VideoCaption = res.body.data[0]
|
const caption1 = body.data[0]
|
||||||
expect(caption1.language.id).to.equal('ar')
|
expect(caption1.language.id).to.equal('ar')
|
||||||
expect(caption1.language.label).to.equal('Arabic')
|
expect(caption1.language.label).to.equal('Arabic')
|
||||||
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
|
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
|
||||||
await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.')
|
await testCaptionFile(server.url, caption1.captionPath, 'Subtitle good 1.')
|
||||||
|
|
||||||
const caption2: VideoCaption = res.body.data[1]
|
const caption2 = body.data[1]
|
||||||
expect(caption2.language.id).to.equal('zh')
|
expect(caption2.language.id).to.equal('zh')
|
||||||
expect(caption2.language.label).to.equal('Chinese')
|
expect(caption2.language.label).to.equal('Chinese')
|
||||||
expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$'))
|
expect(caption2.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-zh.vtt$'))
|
||||||
|
@ -99,9 +90,7 @@ describe('Test video captions', function () {
|
||||||
it('Should replace an existing caption', async function () {
|
it('Should replace an existing caption', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await createVideoCaption({
|
await servers[0].captionsCommand.createVideoCaption({
|
||||||
url: servers[0].url,
|
|
||||||
accessToken: servers[0].accessToken,
|
|
||||||
language: 'ar',
|
language: 'ar',
|
||||||
videoId: videoUUID,
|
videoId: videoUUID,
|
||||||
fixture: 'subtitle-good2.vtt'
|
fixture: 'subtitle-good2.vtt'
|
||||||
|
@ -112,11 +101,11 @@ describe('Test video captions', function () {
|
||||||
|
|
||||||
it('Should have this caption updated', async function () {
|
it('Should have this caption updated', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const res = await listVideoCaptions(server.url, videoUUID)
|
const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
|
||||||
expect(res.body.total).to.equal(2)
|
expect(body.total).to.equal(2)
|
||||||
expect(res.body.data).to.have.lengthOf(2)
|
expect(body.data).to.have.lengthOf(2)
|
||||||
|
|
||||||
const caption1: VideoCaption = res.body.data[0]
|
const caption1 = body.data[0]
|
||||||
expect(caption1.language.id).to.equal('ar')
|
expect(caption1.language.id).to.equal('ar')
|
||||||
expect(caption1.language.label).to.equal('Arabic')
|
expect(caption1.language.label).to.equal('Arabic')
|
||||||
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
|
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
|
||||||
|
@ -127,9 +116,7 @@ describe('Test video captions', function () {
|
||||||
it('Should replace an existing caption with a srt file and convert it', async function () {
|
it('Should replace an existing caption with a srt file and convert it', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await createVideoCaption({
|
await servers[0].captionsCommand.createVideoCaption({
|
||||||
url: servers[0].url,
|
|
||||||
accessToken: servers[0].accessToken,
|
|
||||||
language: 'ar',
|
language: 'ar',
|
||||||
videoId: videoUUID,
|
videoId: videoUUID,
|
||||||
fixture: 'subtitle-good.srt'
|
fixture: 'subtitle-good.srt'
|
||||||
|
@ -143,11 +130,11 @@ describe('Test video captions', function () {
|
||||||
|
|
||||||
it('Should have this caption updated and converted', async function () {
|
it('Should have this caption updated and converted', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const res = await listVideoCaptions(server.url, videoUUID)
|
const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
|
||||||
expect(res.body.total).to.equal(2)
|
expect(body.total).to.equal(2)
|
||||||
expect(res.body.data).to.have.lengthOf(2)
|
expect(body.data).to.have.lengthOf(2)
|
||||||
|
|
||||||
const caption1: VideoCaption = res.body.data[0]
|
const caption1 = body.data[0]
|
||||||
expect(caption1.language.id).to.equal('ar')
|
expect(caption1.language.id).to.equal('ar')
|
||||||
expect(caption1.language.label).to.equal('Arabic')
|
expect(caption1.language.label).to.equal('Arabic')
|
||||||
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
|
expect(caption1.captionPath).to.match(new RegExp('^/lazy-static/video-captions/' + uuidRegex + '-ar.vtt$'))
|
||||||
|
@ -172,18 +159,18 @@ describe('Test video captions', function () {
|
||||||
it('Should remove one caption', async function () {
|
it('Should remove one caption', async function () {
|
||||||
this.timeout(30000)
|
this.timeout(30000)
|
||||||
|
|
||||||
await deleteVideoCaption(servers[0].url, servers[0].accessToken, videoUUID, 'ar')
|
await servers[0].captionsCommand.deleteVideoCaption({ videoId: videoUUID, language: 'ar' })
|
||||||
|
|
||||||
await waitJobs(servers)
|
await waitJobs(servers)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Should only list the caption that was not deleted', async function () {
|
it('Should only list the caption that was not deleted', async function () {
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
const res = await listVideoCaptions(server.url, videoUUID)
|
const body = await server.captionsCommand.listVideoCaptions({ videoId: videoUUID })
|
||||||
expect(res.body.total).to.equal(1)
|
expect(body.total).to.equal(1)
|
||||||
expect(res.body.data).to.have.lengthOf(1)
|
expect(body.data).to.have.lengthOf(1)
|
||||||
|
|
||||||
const caption: VideoCaption = res.body.data[0]
|
const caption = body.data[0]
|
||||||
|
|
||||||
expect(caption.language.id).to.equal('zh')
|
expect(caption.language.id).to.equal('zh')
|
||||||
expect(caption.language.label).to.equal('Chinese')
|
expect(caption.language.label).to.equal('Chinese')
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
getVideo,
|
getVideo,
|
||||||
getVideosList,
|
getVideosList,
|
||||||
immutableAssign,
|
immutableAssign,
|
||||||
listVideoCaptions,
|
|
||||||
ServerInfo,
|
ServerInfo,
|
||||||
setAccessTokensToServers,
|
setAccessTokensToServers,
|
||||||
testCaptionFile
|
testCaptionFile
|
||||||
|
@ -25,7 +24,7 @@ import {
|
||||||
getYoutubeVideoUrl,
|
getYoutubeVideoUrl,
|
||||||
importVideo
|
importVideo
|
||||||
} from '../../../../shared/extra-utils/videos/video-imports'
|
} from '../../../../shared/extra-utils/videos/video-imports'
|
||||||
import { VideoCaption, VideoDetails, VideoImport, VideoPrivacy, VideoResolution } from '../../../../shared/models/videos'
|
import { VideoDetails, VideoImport, VideoPrivacy, VideoResolution } from '../../../../shared/models/videos'
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
|
@ -36,8 +35,8 @@ describe('Test video imports', function () {
|
||||||
|
|
||||||
if (areHttpImportTestsDisabled()) return
|
if (areHttpImportTestsDisabled()) return
|
||||||
|
|
||||||
async function checkVideosServer1 (url: string, idHttp: string, idMagnet: string, idTorrent: string) {
|
async function checkVideosServer1 (server: ServerInfo, idHttp: string, idMagnet: string, idTorrent: string) {
|
||||||
const resHttp = await getVideo(url, idHttp)
|
const resHttp = await getVideo(server.url, idHttp)
|
||||||
const videoHttp: VideoDetails = resHttp.body
|
const videoHttp: VideoDetails = resHttp.body
|
||||||
|
|
||||||
expect(videoHttp.name).to.equal('small video - youtube')
|
expect(videoHttp.name).to.equal('small video - youtube')
|
||||||
|
@ -55,9 +54,9 @@ describe('Test video imports', function () {
|
||||||
expect(originallyPublishedAt.getMonth()).to.equal(0)
|
expect(originallyPublishedAt.getMonth()).to.equal(0)
|
||||||
expect(originallyPublishedAt.getFullYear()).to.equal(2019)
|
expect(originallyPublishedAt.getFullYear()).to.equal(2019)
|
||||||
|
|
||||||
const resMagnet = await getVideo(url, idMagnet)
|
const resMagnet = await getVideo(server.url, idMagnet)
|
||||||
const videoMagnet: VideoDetails = resMagnet.body
|
const videoMagnet: VideoDetails = resMagnet.body
|
||||||
const resTorrent = await getVideo(url, idTorrent)
|
const resTorrent = await getVideo(server.url, idTorrent)
|
||||||
const videoTorrent: VideoDetails = resTorrent.body
|
const videoTorrent: VideoDetails = resTorrent.body
|
||||||
|
|
||||||
for (const video of [ videoMagnet, videoTorrent ]) {
|
for (const video of [ videoMagnet, videoTorrent ]) {
|
||||||
|
@ -73,12 +72,12 @@ describe('Test video imports', function () {
|
||||||
expect(videoTorrent.name).to.contain('你好 世界 720p.mp4')
|
expect(videoTorrent.name).to.contain('你好 世界 720p.mp4')
|
||||||
expect(videoMagnet.name).to.contain('super peertube2 video')
|
expect(videoMagnet.name).to.contain('super peertube2 video')
|
||||||
|
|
||||||
const resCaptions = await listVideoCaptions(url, idHttp)
|
const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: idHttp })
|
||||||
expect(resCaptions.body.total).to.equal(2)
|
expect(bodyCaptions.total).to.equal(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkVideoServer2 (url: string, id: number | string) {
|
async function checkVideoServer2 (server: ServerInfo, id: number | string) {
|
||||||
const res = await getVideo(url, id)
|
const res = await getVideo(server.url, id)
|
||||||
const video: VideoDetails = res.body
|
const video: VideoDetails = res.body
|
||||||
|
|
||||||
expect(video.name).to.equal('my super name')
|
expect(video.name).to.equal('my super name')
|
||||||
|
@ -91,8 +90,8 @@ describe('Test video imports', function () {
|
||||||
|
|
||||||
expect(video.files).to.have.lengthOf(1)
|
expect(video.files).to.have.lengthOf(1)
|
||||||
|
|
||||||
const resCaptions = await listVideoCaptions(url, id)
|
const bodyCaptions = await server.captionsCommand.listVideoCaptions({ videoId: id })
|
||||||
expect(resCaptions.body.total).to.equal(2)
|
expect(bodyCaptions.total).to.equal(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
before(async function () {
|
before(async function () {
|
||||||
|
@ -135,8 +134,8 @@ describe('Test video imports', function () {
|
||||||
await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath)
|
await testImage(servers[0].url, 'video_import_thumbnail', res.body.video.thumbnailPath)
|
||||||
await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath)
|
await testImage(servers[0].url, 'video_import_preview', res.body.video.previewPath)
|
||||||
|
|
||||||
const resCaptions = await listVideoCaptions(servers[0].url, res.body.video.id)
|
const bodyCaptions = await servers[0].captionsCommand.listVideoCaptions({ videoId: res.body.video.id })
|
||||||
const videoCaptions: VideoCaption[] = resCaptions.body.data
|
const videoCaptions = bodyCaptions.data
|
||||||
expect(videoCaptions).to.have.lengthOf(2)
|
expect(videoCaptions).to.have.lengthOf(2)
|
||||||
|
|
||||||
const enCaption = videoCaptions.find(caption => caption.language.id === 'en')
|
const enCaption = videoCaptions.find(caption => caption.language.id === 'en')
|
||||||
|
@ -241,7 +240,7 @@ Ajouter un sous-titre est vraiment facile`)
|
||||||
expect(res.body.data).to.have.lengthOf(3)
|
expect(res.body.data).to.have.lengthOf(3)
|
||||||
|
|
||||||
const [ videoHttp, videoMagnet, videoTorrent ] = res.body.data
|
const [ videoHttp, videoMagnet, videoTorrent ] = res.body.data
|
||||||
await checkVideosServer1(server.url, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
|
await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -273,10 +272,10 @@ Ajouter un sous-titre est vraiment facile`)
|
||||||
expect(res.body.total).to.equal(4)
|
expect(res.body.total).to.equal(4)
|
||||||
expect(res.body.data).to.have.lengthOf(4)
|
expect(res.body.data).to.have.lengthOf(4)
|
||||||
|
|
||||||
await checkVideoServer2(server.url, res.body.data[0].uuid)
|
await checkVideoServer2(server, res.body.data[0].uuid)
|
||||||
|
|
||||||
const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data
|
const [ , videoHttp, videoMagnet, videoTorrent ] = res.body.data
|
||||||
await checkVideosServer1(server.url, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
|
await checkVideosServer1(server, videoHttp.uuid, videoMagnet.uuid, videoTorrent.uuid)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { makeGetRequest } from '../requests/requests'
|
||||||
import { SearchCommand } from '../search'
|
import { SearchCommand } from '../search'
|
||||||
import { SocketIOCommand } from '../socket'
|
import { SocketIOCommand } from '../socket'
|
||||||
import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users'
|
import { AccountsCommand, BlocklistCommand, SubscriptionsCommand } from '../users'
|
||||||
import { LiveCommand, ServicesCommand, BlacklistCommand } from '../videos'
|
import { LiveCommand, ServicesCommand, BlacklistCommand, CaptionsCommand } from '../videos'
|
||||||
import { ConfigCommand } from './config-command'
|
import { ConfigCommand } from './config-command'
|
||||||
import { ContactFormCommand } from './contact-form-command'
|
import { ContactFormCommand } from './contact-form-command'
|
||||||
import { DebugCommand } from './debug-command'
|
import { DebugCommand } from './debug-command'
|
||||||
|
@ -103,6 +103,7 @@ interface ServerInfo {
|
||||||
liveCommand?: LiveCommand
|
liveCommand?: LiveCommand
|
||||||
servicesCommand?: ServicesCommand
|
servicesCommand?: ServicesCommand
|
||||||
blacklistCommand?: BlacklistCommand
|
blacklistCommand?: BlacklistCommand
|
||||||
|
captionsCommand?: CaptionsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
function parallelTests () {
|
function parallelTests () {
|
||||||
|
@ -331,6 +332,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = []
|
||||||
server.liveCommand = new LiveCommand(server)
|
server.liveCommand = new LiveCommand(server)
|
||||||
server.servicesCommand = new ServicesCommand(server)
|
server.servicesCommand = new ServicesCommand(server)
|
||||||
server.blacklistCommand = new BlacklistCommand(server)
|
server.blacklistCommand = new BlacklistCommand(server)
|
||||||
|
server.captionsCommand = new CaptionsCommand(server)
|
||||||
|
|
||||||
res(server)
|
res(server)
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
import { ResultList, VideoCaption } from '@shared/models'
|
||||||
|
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
||||||
|
import { buildAbsoluteFixturePath } from '../miscs/miscs'
|
||||||
|
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||||
|
|
||||||
|
export class CaptionsCommand extends AbstractCommand {
|
||||||
|
|
||||||
|
createVideoCaption (options: OverrideCommandOptions & {
|
||||||
|
videoId: string | number
|
||||||
|
language: string
|
||||||
|
fixture: string
|
||||||
|
mimeType?: string
|
||||||
|
}) {
|
||||||
|
const { videoId, language, fixture, mimeType } = options
|
||||||
|
|
||||||
|
const path = '/api/v1/videos/' + videoId + '/captions/' + language
|
||||||
|
|
||||||
|
const captionfile = buildAbsoluteFixturePath(fixture)
|
||||||
|
const captionfileAttach = mimeType
|
||||||
|
? [ captionfile, { contentType: mimeType } ]
|
||||||
|
: captionfile
|
||||||
|
|
||||||
|
return this.putUploadRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
fields: {},
|
||||||
|
attaches: {
|
||||||
|
captionfile: captionfileAttach
|
||||||
|
},
|
||||||
|
implicitToken: true,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
listVideoCaptions (options: OverrideCommandOptions & {
|
||||||
|
videoId: string | number
|
||||||
|
}) {
|
||||||
|
const { videoId } = options
|
||||||
|
const path = '/api/v1/videos/' + videoId + '/captions'
|
||||||
|
|
||||||
|
return this.getRequestBody<ResultList<VideoCaption>>({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
implicitToken: false,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteVideoCaption (options: OverrideCommandOptions & {
|
||||||
|
videoId: string | number
|
||||||
|
language: string
|
||||||
|
}) {
|
||||||
|
const { videoId, language } = options
|
||||||
|
const path = '/api/v1/videos/' + videoId + '/captions/' + language
|
||||||
|
|
||||||
|
return this.deleteRequest({
|
||||||
|
...options,
|
||||||
|
|
||||||
|
path,
|
||||||
|
implicitToken: true,
|
||||||
|
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { expect } from 'chai'
|
||||||
|
import * as request from 'supertest'
|
||||||
|
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
|
||||||
|
|
||||||
|
async function testCaptionFile (url: string, captionPath: string, containsString: string) {
|
||||||
|
const res = await request(url)
|
||||||
|
.get(captionPath)
|
||||||
|
.expect(HttpStatusCode.OK_200)
|
||||||
|
|
||||||
|
expect(res.text).to.contain(containsString)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export {
|
||||||
|
testCaptionFile
|
||||||
|
}
|
|
@ -1,8 +1,9 @@
|
||||||
export * from './blacklist-command'
|
export * from './blacklist-command'
|
||||||
|
export * from './captions'
|
||||||
|
export * from './captions-command'
|
||||||
export * from './live-command'
|
export * from './live-command'
|
||||||
export * from './live'
|
export * from './live'
|
||||||
export * from './services-command'
|
export * from './services-command'
|
||||||
export * from './video-captions'
|
|
||||||
export * from './video-change-ownership'
|
export * from './video-change-ownership'
|
||||||
export * from './video-channels'
|
export * from './video-channels'
|
||||||
export * from './video-comments'
|
export * from './video-comments'
|
||||||
|
|
|
@ -1,72 +0,0 @@
|
||||||
import { makeDeleteRequest, makeGetRequest, makeUploadRequest } from '../requests/requests'
|
|
||||||
import * as request from 'supertest'
|
|
||||||
import * as chai from 'chai'
|
|
||||||
import { buildAbsoluteFixturePath } from '../miscs/miscs'
|
|
||||||
import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
|
||||||
|
|
||||||
function createVideoCaption (args: {
|
|
||||||
url: string
|
|
||||||
accessToken: string
|
|
||||||
videoId: string | number
|
|
||||||
language: string
|
|
||||||
fixture: string
|
|
||||||
mimeType?: string
|
|
||||||
statusCodeExpected?: number
|
|
||||||
}) {
|
|
||||||
const path = '/api/v1/videos/' + args.videoId + '/captions/' + args.language
|
|
||||||
|
|
||||||
const captionfile = buildAbsoluteFixturePath(args.fixture)
|
|
||||||
const captionfileAttach = args.mimeType ? [ captionfile, { contentType: args.mimeType } ] : captionfile
|
|
||||||
|
|
||||||
return makeUploadRequest({
|
|
||||||
method: 'PUT',
|
|
||||||
url: args.url,
|
|
||||||
path,
|
|
||||||
token: args.accessToken,
|
|
||||||
fields: {},
|
|
||||||
attaches: {
|
|
||||||
captionfile: captionfileAttach
|
|
||||||
},
|
|
||||||
statusCodeExpected: args.statusCodeExpected || HttpStatusCode.NO_CONTENT_204
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function listVideoCaptions (url: string, videoId: string | number) {
|
|
||||||
const path = '/api/v1/videos/' + videoId + '/captions'
|
|
||||||
|
|
||||||
return makeGetRequest({
|
|
||||||
url,
|
|
||||||
path,
|
|
||||||
statusCodeExpected: HttpStatusCode.OK_200
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteVideoCaption (url: string, token: string, videoId: string | number, language: string) {
|
|
||||||
const path = '/api/v1/videos/' + videoId + '/captions/' + language
|
|
||||||
|
|
||||||
return makeDeleteRequest({
|
|
||||||
url,
|
|
||||||
token,
|
|
||||||
path,
|
|
||||||
statusCodeExpected: HttpStatusCode.NO_CONTENT_204
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function testCaptionFile (url: string, captionPath: string, containsString: string) {
|
|
||||||
const res = await request(url)
|
|
||||||
.get(captionPath)
|
|
||||||
.expect(HttpStatusCode.OK_200)
|
|
||||||
|
|
||||||
expect(res.text).to.contain(containsString)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
export {
|
|
||||||
createVideoCaption,
|
|
||||||
listVideoCaptions,
|
|
||||||
testCaptionFile,
|
|
||||||
deleteVideoCaption
|
|
||||||
}
|
|
Loading…
Reference in New Issue