aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-07-16 14:22:16 +0200
committerChocobozzz <me@florianbigard.com>2018-07-16 14:31:40 +0200
commitf4001cf408a99049d01a356bfb20a62342de06ea (patch)
tree421776dfe64335dca2725ac3ac5f3b3e6b7564c6 /server/tests/api/videos
parent16f7022b06fb76c0b00c23c970bc8df605b0ec63 (diff)
downloadPeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.gz
PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.tar.zst
PeerTube-f4001cf408a99049d01a356bfb20a62342de06ea.zip
Handle .srt subtitles
Diffstat (limited to 'server/tests/api/videos')
-rw-r--r--server/tests/api/videos/video-captions.ts53
1 files changed, 52 insertions, 1 deletions
diff --git a/server/tests/api/videos/video-captions.ts b/server/tests/api/videos/video-captions.ts
index cbf5268f0..eb73c5baf 100644
--- a/server/tests/api/videos/video-captions.ts
+++ b/server/tests/api/videos/video-captions.ts
@@ -2,7 +2,7 @@
2 2
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { doubleFollow, flushAndRunMultipleServers, uploadVideo } from '../../utils' 5import { checkVideoFilesWereRemoved, doubleFollow, flushAndRunMultipleServers, removeVideo, uploadVideo, wait } from '../../utils'
6import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index' 6import { flushTests, killallServers, ServerInfo, setAccessTokensToServers } from '../../utils/index'
7import { waitJobs } from '../../utils/server/jobs' 7import { waitJobs } from '../../utils/server/jobs'
8import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions' 8import { createVideoCaption, deleteVideoCaption, listVideoCaptions, testCaptionFile } from '../../utils/videos/video-captions'
@@ -110,6 +110,51 @@ describe('Test video captions', function () {
110 } 110 }
111 }) 111 })
112 112
113 it('Should replace an existing caption with a srt file and convert it', async function () {
114 this.timeout(30000)
115
116 await createVideoCaption({
117 url: servers[0].url,
118 accessToken: servers[0].accessToken,
119 language: 'ar',
120 videoId: videoUUID,
121 fixture: 'subtitle-good.srt'
122 })
123
124 await waitJobs(servers)
125
126 // Cache invalidation
127 await wait(3000)
128 })
129
130 it('Should have this caption updated and converted', async function () {
131 for (const server of servers) {
132 const res = await listVideoCaptions(server.url, videoUUID)
133 expect(res.body.total).to.equal(2)
134 expect(res.body.data).to.have.lengthOf(2)
135
136 const caption1: VideoCaption = res.body.data[0]
137 expect(caption1.language.id).to.equal('ar')
138 expect(caption1.language.label).to.equal('Arabic')
139 expect(caption1.captionPath).to.equal('/static/video-captions/' + videoUUID + '-ar.vtt')
140
141 const expected = 'WEBVTT FILE\r\n' +
142 '\r\n' +
143 '1\r\n' +
144 '00:00:01.600 --> 00:00:04.200\r\n' +
145 'English (US)\r\n' +
146 '\r\n' +
147 '2\r\n' +
148 '00:00:05.900 --> 00:00:07.999\r\n' +
149 'This is a subtitle in American English\r\n' +
150 '\r\n' +
151 '3\r\n' +
152 '00:00:10.000 --> 00:00:14.000\r\n' +
153 'Adding subtitles is very easy to do\r\n'
154 await testCaptionFile(server.url, caption1.captionPath, expected)
155 }
156 })
157
113 it('Should remove one caption', async function () { 158 it('Should remove one caption', async function () {
114 this.timeout(30000) 159 this.timeout(30000)
115 160
@@ -133,6 +178,12 @@ describe('Test video captions', function () {
133 } 178 }
134 }) 179 })
135 180
181 it('Should remove the video, and thus all video captions', async function () {
182 await removeVideo(servers[0].url, servers[0].accessToken, videoUUID)
183
184 await checkVideoFilesWereRemoved(videoUUID, 1)
185 })
186
136 after(async function () { 187 after(async function () {
137 killallServers(servers) 188 killallServers(servers)
138 }) 189 })