diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-02 16:05:44 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-02 16:05:44 +0200 |
commit | ebb9e53ada156249ed8e8cfd1de74097d3eb49d7 (patch) | |
tree | 094873e9f09a30eedf48617d4af3d4a3232df0fb /server/tests | |
parent | 22df69fdecf299c8be6acaa25f086249ea9a0085 (diff) | |
download | PeerTube-ebb9e53ada156249ed8e8cfd1de74097d3eb49d7.tar.gz PeerTube-ebb9e53ada156249ed8e8cfd1de74097d3eb49d7.tar.zst PeerTube-ebb9e53ada156249ed8e8cfd1de74097d3eb49d7.zip |
Add plugin hook on transcoding resolutions building
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test/main.js | 13 | ||||
-rw-r--r-- | server/tests/plugins/filter-hooks.ts | 13 |
2 files changed, 24 insertions, 2 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test/main.js b/server/tests/fixtures/peertube-plugin-test/main.js index f62f6a435..c395ac7aa 100644 --- a/server/tests/fixtures/peertube-plugin-test/main.js +++ b/server/tests/fixtures/peertube-plugin-test/main.js | |||
@@ -256,8 +256,6 @@ async function register ({ registerHook, registerSetting, settingsManager, stora | |||
256 | registerHook({ | 256 | registerHook({ |
257 | target: 'filter:job-queue.process.params', | 257 | target: 'filter:job-queue.process.params', |
258 | handler: (object, context) => { | 258 | handler: (object, context) => { |
259 | peertubeHelpers.logger.debug('TOTO.', { object, context }) | ||
260 | |||
261 | if (context.type !== 'video-studio-edition') return object | 259 | if (context.type !== 'video-studio-edition') return object |
262 | 260 | ||
263 | object.data.tasks = [ | 261 | object.data.tasks = [ |
@@ -274,6 +272,17 @@ async function register ({ registerHook, registerSetting, settingsManager, stora | |||
274 | } | 272 | } |
275 | }) | 273 | }) |
276 | 274 | ||
275 | registerHook({ | ||
276 | target: 'filter:transcoding.auto.lower-resolutions-to-transcode.result', | ||
277 | handler: (object, context) => { | ||
278 | if (context.video.name.includes('transcode-filter')) { | ||
279 | object = [ 100 ] | ||
280 | } | ||
281 | |||
282 | return object | ||
283 | } | ||
284 | }) | ||
285 | |||
277 | // Upload/import/live attributes | 286 | // Upload/import/live attributes |
278 | for (const target of [ | 287 | for (const target of [ |
279 | 'filter:api.video.upload.video-attribute.result', | 288 | 'filter:api.video.upload.video-attribute.result', |
diff --git a/server/tests/plugins/filter-hooks.ts b/server/tests/plugins/filter-hooks.ts index 27b72cf7d..33feadab6 100644 --- a/server/tests/plugins/filter-hooks.ts +++ b/server/tests/plugins/filter-hooks.ts | |||
@@ -677,6 +677,19 @@ describe('Test plugin filter hooks', function () { | |||
677 | }) | 677 | }) |
678 | }) | 678 | }) |
679 | 679 | ||
680 | describe('Transcoding filters', async function () { | ||
681 | |||
682 | it('Should run filter:transcoding.auto.lower-resolutions-to-transcode.result', async function () { | ||
683 | const { uuid } = await servers[0].videos.quickUpload({ name: 'transcode-filter' }) | ||
684 | |||
685 | await waitJobs(servers) | ||
686 | |||
687 | const video = await servers[0].videos.get({ id: uuid }) | ||
688 | expect(video.files).to.have.lengthOf(2) | ||
689 | expect(video.files.find(f => f.resolution.id === 100 as any)).to.exist | ||
690 | }) | ||
691 | }) | ||
692 | |||
680 | after(async function () { | 693 | after(async function () { |
681 | await cleanupTests(servers) | 694 | await cleanupTests(servers) |
682 | }) | 695 | }) |