From 754c52b9b998a825fd830d5ac527a67e0eefeb9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Dec 2021 17:00:46 +0100 Subject: Add ffprobe helper --- server/tests/fixtures/peertube-plugin-test-four/main.js | 7 +++++++ server/tests/plugins/plugin-helpers.ts | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'server/tests') diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/server/tests/fixtures/peertube-plugin-test-four/main.js index edbb883e2..bff42ff40 100644 --- a/server/tests/fixtures/peertube-plugin-test-four/main.js +++ b/server/tests/fixtures/peertube-plugin-test-four/main.js @@ -111,6 +111,13 @@ async function register ({ return res.json(details) }) + + router.get('/ffprobe', async (req, res) => { + const result = await peertubeHelpers.videos.ffprobe(req.query.path) + if (!result) return res.sendStatus(404) + + return res.json(result) + }) } } diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts index 26f66b0b1..da84658bb 100644 --- a/server/tests/plugins/plugin-helpers.ts +++ b/server/tests/plugins/plugin-helpers.ts @@ -224,6 +224,7 @@ describe('Test plugin helpers', function () { describe('Videos', function () { let videoUUID: string + let videoPath: string before(async () => { this.timeout(240000) @@ -260,6 +261,8 @@ describe('Test plugin helpers', function () { await makeRawRequest(file.url, HttpStatusCode.OK_200) } } + + videoPath = body.webtorrent.videoFiles[0].path } // Thumbnails check @@ -278,6 +281,20 @@ describe('Test plugin helpers', function () { } }) + it('Should probe a file', async function () { + const { body } = await makeGetRequest({ + url: servers[0].url, + path: '/plugins/test-four/router/ffprobe', + query: { + path: videoPath + }, + expectedStatus: HttpStatusCode.OK_200 + }) + + expect(body.streams).to.be.an('array') + expect(body.streams).to.have.lengthOf(2) + }) + it('Should remove a video after a view', async function () { this.timeout(40000) -- cgit v1.2.3